src/Entity/Project.php line 19

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  7. use App\Entity\File;
  8. use App\Entity\Config;
  9. use Gedmo\Mapping\Annotation as Gedmo;
  10. /**
  11.  * @ORM\Entity(repositoryClass="App\Repository\ProjectRepository")
  12.  * @UniqueEntity(fields="botname", message="Botname is already taken.")
  13.  */
  14. class Project
  15. {
  16.     /**
  17.      * @ORM\Id()
  18.      * @ORM\GeneratedValue()
  19.      * @ORM\Column(type="integer")
  20.      */
  21.     private $id;
  22.     /**
  23.      * @ORM\Column(type="string", length=255)
  24.      */
  25.     private $name;
  26.     /**
  27.      * @ORM\Column(type="text", nullable=true)
  28.      */
  29.     private $description;
  30.     /**
  31.      * @ORM\Column(type="string", length=255, unique=true)
  32.      */
  33.     private $botname;
  34.     /**
  35.      * @ORM\OneToMany(targetEntity="App\Entity\Repo", mappedBy="project", orphanRemoval=true, cascade={"persist"})
  36.      */
  37.     private $repos;
  38.     /**
  39.      * @ORM\OneToMany(targetEntity="App\Entity\Environment", mappedBy="project", orphanRemoval=true)
  40.      */
  41.     private $environment;
  42.     /**
  43.      * @ORM\OneToMany(targetEntity="App\Entity\Job", mappedBy="project", orphanRemoval=true, cascade={"persist"})
  44.      */
  45.     private $jobs;
  46.     /**
  47.      * @ORM\Column(type="array", nullable=true)
  48.      */
  49.     private $builds = [];
  50.     /**
  51.      * @ORM\OneToMany(targetEntity="App\Entity\DeployTag", mappedBy="project", orphanRemoval=true, cascade={"persist"})
  52.      * @ORM\OrderBy({"name" = "DESC"})
  53.      */
  54.     private $deployTags;
  55.     /**
  56.      * @ORM\ManyToOne(targetEntity="App\Entity\Config")
  57.      */
  58.     private $tempoTeam;
  59.     /**
  60.      * @ORM\ManyToOne(targetEntity="App\Entity\Config")
  61.      * @ORM\JoinColumn(nullable=false)
  62.      */
  63.     private $type;
  64.     /**
  65.      * @ORM\OneToMany(targetEntity="App\Entity\DbImpExp", mappedBy="project", orphanRemoval=true, cascade={"persist"})
  66.      * @ORM\OrderBy({"date" = "DESC"})
  67.      */
  68.     private $dbImpExps;
  69.     /**
  70.      * @ORM\Column(type="string", length=255, nullable=true)
  71.      */
  72.     private $containerRegistryUsername;
  73.     /**
  74.      * @ORM\Column(type="string", length=255, nullable=true)
  75.      */
  76.     private $containerRegistryPassword;
  77.     /**
  78.      * @ORM\ManyToOne(targetEntity="App\Entity\Config")
  79.      * @ORM\JoinColumn(nullable=false)
  80.      */
  81.     private $sla;
  82.     /**
  83.      * @ORM\OneToMany(targetEntity="App\Entity\SLAChange", mappedBy="project", orphanRemoval=true)
  84.      */
  85.     private $slaChanges;
  86.     /**
  87.      * @ORM\Column(type="string", length=255, nullable=true)
  88.      */
  89.     private $slasecret;
  90.     /**
  91.      * @ORM\OneToMany(targetEntity=CHEQContract::class, mappedBy="project", orphanRemoval=true)
  92.      */
  93.     private $CHEQContracts;
  94.     /**
  95.      * @ORM\OneToMany(targetEntity=File::class, mappedBy="Project", orphanRemoval=true, cascade={"persist"})
  96.      */
  97.     private $files;
  98.     /**
  99.      * @ORM\ManyToOne(targetEntity=Config::class)
  100.      * @ORM\JoinColumn(nullable=false)
  101.      */
  102.     private $devCompany;
  103.     /**
  104.      * @ORM\OneToOne(targetEntity=AzureMarketplace::class, mappedBy="project", cascade={"persist", "remove"}, orphanRemoval=true)
  105.      */
  106.     private $azureMarketplace;
  107.     /**
  108.      * @ORM\OneToOne(targetEntity=ApiUsers::class, mappedBy="project", cascade={"persist", "remove"})
  109.      */
  110.     private $apiUsers;
  111.     /**
  112.      * @var \DateTime $created
  113.      *
  114.      * @Gedmo\Timestampable(on="create")
  115.      * @ORM\Column(type="datetime")
  116.      */
  117.     private $created;
  118.     /**
  119.      * @var \DateTime $updated
  120.      *
  121.      * @Gedmo\Timestampable(on="update")
  122.      * @ORM\Column(type="datetime")
  123.      */
  124.     private $updated;
  125.     /**
  126.      * @ORM\OneToMany(targetEntity=IOSCode::class, mappedBy="project", orphanRemoval=true)
  127.      */
  128.     private $iOSCodes;
  129.     /**
  130.      * @ORM\Column(type="text", nullable=true)
  131.      */
  132.     private $mobileappDescription;
  133.     
  134.         /**
  135.      * @ORM\Column(type="text", nullable=true)
  136.      */
  137.     private $mobileappIntro;
  138.     /**
  139.      * @ORM\Column(type="string", length=255, nullable=true)
  140.      */
  141.     private $botIdentityName;
  142.     /**
  143.      * @ORM\Column(type="string", length=255, nullable=true)
  144.      */
  145.     private $iosLink;
  146.     /**
  147.      * @ORM\Column(type="string", length=255, nullable=true)
  148.      */
  149.     private $androidLink;
  150.     /**
  151.      * @ORM\Column(type="string", length=255, nullable=true)
  152.      */
  153.     private $viberLink;
  154.     /**
  155.      * @ORM\OneToMany(targetEntity=Secret::class, mappedBy="project")
  156.      */
  157.     private $secrets;
  158.     
  159.     
  160.     public function __construct()
  161.     {
  162.         $this->repos = new ArrayCollection();
  163.         $this->environment = new ArrayCollection();
  164.         $this->jobs = new ArrayCollection();
  165.         $this->deployTags = new ArrayCollection();
  166.         $this->dbImpExps = new ArrayCollection();
  167.         $this->slaChanges = new ArrayCollection();
  168.         $this->CHEQContracts = new ArrayCollection();
  169.         $this->files = new ArrayCollection();
  170.         $this->iOSCodes = new ArrayCollection();
  171.         $this->secrets = new ArrayCollection();
  172.     }
  173.     public function getId(): ?int
  174.     {
  175.         return $this->id;
  176.     }
  177.     public function getName(): ?string
  178.     {
  179.         return $this->name;
  180.     }
  181.     public function setName(string $name): self
  182.     {
  183.         $this->name $name;
  184.         return $this;
  185.     }
  186.     public function getDescription(): ?string
  187.     {
  188.         return $this->description;
  189.     }
  190.     public function setDescription(?string $description): self
  191.     {
  192.         $this->description $description;
  193.         return $this;
  194.     }
  195.     public function getBotname(): ?string
  196.     {
  197.         return $this->botname;
  198.     }
  199.     public function setBotname(string $botname): self
  200.     {
  201.         $this->botname strtolower($botname);
  202.         return $this;
  203.     }
  204.     /**
  205.      * @return Collection|Repo[]
  206.      */
  207.     public function getRepos(): Collection
  208.     {
  209.         return $this->repos;
  210.     }
  211.     public function addRepo(Repo $repo): self
  212.     {
  213.         if (!$this->repos->contains($repo)) {
  214.             $this->repos[] = $repo;
  215.             $repo->setProject($this);
  216.         }
  217.         return $this;
  218.     }
  219.     public function removeRepo(Repo $repo): self
  220.     {
  221.         if ($this->repos->contains($repo)) {
  222.             $this->repos->removeElement($repo);
  223.             // set the owning side to null (unless already changed)
  224.             if ($repo->getProject() === $this) {
  225.                 $repo->setProject(null);
  226.             }
  227.         }
  228.         return $this;
  229.     }
  230.     public function __toString() {
  231.                                                                                    return $this->name." (".$this->botname.")";
  232.                                                                                }
  233.     /**
  234.      * @return Collection|Environment[]
  235.      */
  236.     public function getEnvironment(): Collection
  237.     {
  238.         return $this->environment;
  239.     }
  240.     public function addEnvironment(Environment $environment): self
  241.     {
  242.         if (!$this->environment->contains($environment)) {
  243.             $this->environment[] = $environment;
  244.             $environment->setProjectId($this);
  245.         }
  246.         return $this;
  247.     }
  248.     public function removeEnvironment(Environment $environment): self
  249.     {
  250.         if ($this->environment->contains($environment)) {
  251.             $this->environment->removeElement($environment);
  252.             // set the owning side to null (unless already changed)
  253.             if ($environment->getProjectId() === $this) {
  254.                 $environment->setProjectId(null);
  255.             }
  256.         }
  257.         return $this;
  258.     }
  259.     /**
  260.      * @return Collection|Job[]
  261.      */
  262.     public function getJobs(): Collection
  263.     {
  264.         return $this->jobs;
  265.     }
  266.     public function addJob(Job $job): self
  267.     {
  268.         if (!$this->jobs->contains($job)) {
  269.             $this->jobs[] = $job;
  270.             $job->setProject($this);
  271.         }
  272.         return $this;
  273.     }
  274.     public function removeJob(Job $job): self
  275.     {
  276.         if ($this->jobs->contains($job)) {
  277.             $this->jobs->removeElement($job);
  278.             // set the owning side to null (unless already changed)
  279.             if ($job->getProject() === $this) {
  280.                 $job->setProject(null);
  281.             }
  282.         }
  283.         return $this;
  284.     }
  285.     public function getBuilds(): ?array
  286.     {
  287.         if(!empty($this->builds)) {
  288.             return array_reverse($this->builds);
  289.         } else {
  290.             return array("0" => "Buildelj elÅ‘bb!");
  291.         }
  292.     }
  293.     public function setBuilds(array $builds): self
  294.     {
  295.         $this->builds $builds;
  296.         return $this;
  297.     }
  298. /**
  299.      * @return Collection|DeployTag[]
  300.      */
  301.     public function getDeployTags(): Collection
  302.     {
  303.         return $this->deployTags;
  304.     }
  305.     public function addDeployTag(DeployTag $deployTag): self
  306.     {
  307.         if (!$this->deployTags->contains($deployTag)) {
  308.             $this->deployTags[] = $deployTag;
  309.             $deployTag->setProject($this);
  310.         }
  311.         return $this;
  312.     }
  313.     public function removeDeployTag(DeployTag $deployTag): self
  314.     {
  315.         if ($this->deployTags->contains($deployTag)) {
  316.             $this->deployTags->removeElement($deployTag);
  317.             // set the owning side to null (unless already changed)
  318.             if ($deployTag->getProject() === $this) {
  319.                 $deployTag->setProject(null);
  320.             }
  321.         }
  322.         return $this;
  323.     }
  324.     public function getTempoTeam(): ?Config
  325.     {
  326.         return $this->tempoTeam;
  327.     }
  328.     public function setTempoTeam(?Config $tempoTeam): self
  329.     {
  330.         $this->tempoTeam $tempoTeam;
  331.         return $this;
  332.     }
  333.     public function getType(): ?Config
  334.     {
  335.         return $this->type;
  336.     }
  337.     public function setType(?Config $type): self
  338.     {
  339.         $this->type $type;
  340.         return $this;
  341.     }
  342.     /**
  343.      * @return Collection|DbImpExp[]
  344.      */
  345.     public function getDbImpExps(): Collection
  346.     {
  347.         return $this->dbImpExps;
  348.     }
  349.     public function addDbImpExp(DbImpExp $dbImpExp): self
  350.     {
  351.         if (!$this->dbImpExps->contains($dbImpExp)) {
  352.             $this->dbImpExps[] = $dbImpExp;
  353.             $dbImpExp->setProject($this);
  354.         }
  355.         return $this;
  356.     }
  357.     public function removeDbImpExp(DbImpExp $dbImpExp): self
  358.     {
  359.         if ($this->dbImpExps->contains($dbImpExp)) {
  360.             $this->dbImpExps->removeElement($dbImpExp);
  361.             // set the owning side to null (unless already changed)
  362.             if ($dbImpExp->getProject() === $this) {
  363.                 $dbImpExp->setProject(null);
  364.             }
  365.         }
  366.         return $this;
  367.     }
  368.     public function getContainerRegistryUsername(): ?string
  369.     {
  370.         return $this->containerRegistryUsername;
  371.     }
  372.     public function setContainerRegistryUsername(?string $containerRegistryUsername): self
  373.     {
  374.         $this->containerRegistryUsername $containerRegistryUsername;
  375.         return $this;
  376.     }
  377.     public function getContainerRegistryPassword(): ?string
  378.     {
  379.         return $this->containerRegistryPassword;
  380.     }
  381.     public function setContainerRegistryPassword(?string $containerRegistryPassword): self
  382.     {
  383.         $this->containerRegistryPassword $containerRegistryPassword;
  384.         return $this;
  385.     }
  386.     public function getSla(): ?Config
  387.     {
  388.         return $this->sla;
  389.     }
  390.     public function setSla(?Config $sla): self
  391.     {
  392.         $this->sla $sla;
  393.         return $this;
  394.     }
  395.     /**
  396.      * @return Collection|SLAChange[]
  397.      */
  398.     public function getSlaChanges(): Collection
  399.     {
  400.         return $this->slaChanges;
  401.     }
  402.     public function addSlaChange(SLAChange $slaChange): self
  403.     {
  404.         if (!$this->slaChanges->contains($slaChange)) {
  405.             $this->slaChanges[] = $slaChange;
  406.             $slaChange->setProject($this);
  407.         }
  408.         return $this;
  409.     }
  410.     public function removeSlaChange(SLAChange $slaChange): self
  411.     {
  412.         if ($this->slaChanges->contains($slaChange)) {
  413.             $this->slaChanges->removeElement($slaChange);
  414.             // set the owning side to null (unless already changed)
  415.             if ($slaChange->getProject() === $this) {
  416.                 $slaChange->setProject(null);
  417.             }
  418.         }
  419.         return $this;
  420.     }
  421.     public function getSlasecret(): ?string
  422.     {
  423.         return $this->slasecret;
  424.     }
  425.     public function setSlasecret(?string $slasecret): self
  426.     {
  427.         $this->slasecret $slasecret;
  428.         return $this;
  429.     }
  430.     /**
  431.      * @return Collection|CHEQContract[]
  432.      */
  433.     public function getCHEQContracts(): Collection
  434.     {
  435.         return $this->CHEQContracts;
  436.     }
  437.     public function addCHEQContract(CHEQContract $cHEQContract): self
  438.     {
  439.         if (!$this->CHEQContracts->contains($cHEQContract)) {
  440.             $this->CHEQContracts[] = $cHEQContract;
  441.             $cHEQContract->setProject($this);
  442.         }
  443.         return $this;
  444.     }
  445.     public function removeCHEQContract(CHEQContract $cHEQContract): self
  446.     {
  447.         if ($this->CHEQContracts->removeElement($cHEQContract)) {
  448.             // set the owning side to null (unless already changed)
  449.             if ($cHEQContract->getProject() === $this) {
  450.                 $cHEQContract->setProject(null);
  451.             }
  452.         }
  453.         return $this;
  454.     }
  455.     /**
  456.      * @return Collection|File[]
  457.      */
  458.     public function getFiles(): Collection
  459.     {
  460.         return $this->files;
  461.     }
  462.     /**
  463.      * @return File
  464.      */
  465.     public function getLogo(): ?File
  466.     {
  467.         $ret null;
  468.         foreach($this->files AS $file) {
  469.             $fileType $file->getType();
  470.             if($fileType->getValue() == "logo") {
  471.                 if($ret != null) {
  472.                     if($ret->getUpdated() <= $file->getUpdated()) {
  473.                         $ret $file;
  474.                     }
  475.                 } else {
  476.                     $ret $file;
  477.                 }
  478.             }
  479.         }
  480.         return $ret;
  481.     }
  482.     /**
  483.      * @return File
  484.      */
  485.     public function getMobileAppBackground(): ?File
  486.     {
  487.         $ret null;
  488.         foreach($this->files AS $file) {
  489.             $fileType $file->getType();
  490.             if($fileType->getValue() == "mobileapp.background") {
  491.                 if($ret != null) {
  492.                     if($ret->getUpdated() <= $file->getUpdated()) {
  493.                         $ret $file;
  494.                     }
  495.                 } else {
  496.                     $ret $file;
  497.                 }
  498.             }
  499.         }
  500.         return $ret;
  501.     }
  502.     /**
  503.      * @return File
  504.      */
  505.     public function getCompanyLogo(): ?File
  506.     {
  507.         $ret null;
  508.         foreach($this->files AS $file) {
  509.             $fileType $file->getType();
  510.             if($fileType->getValue() == "companylogo") {
  511.                 if($ret != null) {
  512.                     if($ret->getUpdated() <= $file->getUpdated()) {
  513.                         $ret $file;
  514.                     }
  515.                 } else {
  516.                     $ret $file;
  517.                 }
  518.             }
  519.         }
  520.         return $ret;
  521.     }
  522.     public function addFile(File $file): self
  523.     {
  524.         if (!$this->files->contains($file)) {
  525.             $this->files[] = $file;
  526.             $file->setProject($this);
  527.         }
  528.         return $this;
  529.     }
  530.     public function removeFile(File $file): self
  531.     {
  532.         if ($this->files->removeElement($file)) {
  533.             // set the owning side to null (unless already changed)
  534.             if ($file->getProject() === $this) {
  535.                 $file->setProject(null);
  536.             }
  537.         }
  538.         return $this;
  539.     }
  540.     public function getDevCompany(): ?Config
  541.     {
  542.         return $this->devCompany;
  543.     }
  544.     public function setDevCompany(?Config $devCompany): self
  545.     {
  546.         $this->devCompany $devCompany;
  547.         return $this;
  548.     }
  549.     public function getAzureMarketplace(): ?AzureMarketplace
  550.     {
  551.         return $this->azureMarketplace;
  552.     }
  553.     public function setAzureMarketplace(AzureMarketplace $azureMarketplace): self
  554.     {
  555.         $this->azureMarketplace $azureMarketplace;
  556.         // set the owning side of the relation if necessary
  557.         if ($azureMarketplace->getProject() !== $this) {
  558.             $azureMarketplace->setProject($this);
  559.         }
  560.         return $this;
  561.     }
  562.     public function getApiUsers(): ?ApiUsers
  563.     {
  564.         return $this->apiUsers;
  565.     }
  566.     public function setApiUsers(?ApiUsers $apiUsers): self
  567.     {
  568.         // unset the owning side of the relation if necessary
  569.         if ($apiUsers === null && $this->apiUsers !== null) {
  570.             $this->apiUsers->setProject(null);
  571.         }
  572.         // set the owning side of the relation if necessary
  573.         if ($apiUsers !== null && $apiUsers->getProject() !== $this) {
  574.             $apiUsers->setProject($this);
  575.         }
  576.         $this->apiUsers $apiUsers;
  577.         return $this;
  578.     }
  579.     
  580.     public function getCreated()
  581.                                                              {
  582.                                                                  return $this->created;
  583.                                                              }
  584.     public function getUpdated()
  585.     {
  586.         return $this->updated;
  587.     }
  588.     /**
  589.      * @return Collection|IOSCode[]
  590.      */
  591.     public function getIOSCodes(): Collection
  592.     {
  593.         return $this->iOSCodes;
  594.     }
  595.     public function addIOSCode(IOSCode $iOSCode): self
  596.     {
  597.         if (!$this->iOSCodes->contains($iOSCode)) {
  598.             $this->iOSCodes[] = $iOSCode;
  599.             $iOSCode->setProject($this);
  600.         }
  601.         return $this;
  602.     }
  603.     public function removeIOSCode(IOSCode $iOSCode): self
  604.     {
  605.         if ($this->iOSCodes->removeElement($iOSCode)) {
  606.             // set the owning side to null (unless already changed)
  607.             if ($iOSCode->getProject() === $this) {
  608.                 $iOSCode->setProject(null);
  609.             }
  610.         }
  611.         return $this;
  612.     }
  613.     public function getMobileappDescription(): ?string
  614.     {
  615.         return $this->mobileappDescription;
  616.     }
  617.     public function setMobileappDescription(?string $mobileappDescription): self
  618.     {
  619.         $this->mobileappDescription $mobileappDescription;
  620.         return $this;
  621.     }
  622.     public function getMobileappIntro(): ?string
  623.     {
  624.         return $this->mobileappIntro;
  625.     }
  626.     public function setMobileappIntro(?string $mobileappIntro): self
  627.     {
  628.         $this->mobileappIntro $mobileappIntro;
  629.         return $this;
  630.     }
  631.     public function getBotIdentityName(): ?string
  632.     {
  633.         return $this->botIdentityName;
  634.     }
  635.     public function setBotIdentityName(?string $botIdentityName): self
  636.     {
  637.         $this->botIdentityName $botIdentityName;
  638.         return $this;
  639.     }
  640.     public function getIosLink(): ?string
  641.     {
  642.         return $this->iosLink;
  643.     }
  644.     public function setIosLink(?string $iosLink): self
  645.     {
  646.         $this->iosLink $iosLink;
  647.         return $this;
  648.     }
  649.     
  650.         public function getAndroidLink(): ?string
  651.     {
  652.         return $this->androidLink;
  653.     }
  654.     public function setAndroidLink(?string $androidLink): self
  655.     {
  656.         $this->androidLink $androidLink;
  657.         return $this;
  658.     }
  659.     public function getViberLink(): ?string
  660.     {
  661.         return $this->viberLink;
  662.     }
  663.     public function setViberLink(?string $viberLink): self
  664.     {
  665.         $this->viberLink $viberLink;
  666.         return $this;
  667.     }
  668.     /**
  669.      * @return Collection|Secret[]
  670.      */
  671.     public function getSecrets(): Collection
  672.     {
  673.         return $this->secrets;
  674.     }
  675.     /**
  676.      * @return Array|Secret[]
  677.      */
  678.     public function getSecretsByEnvTypeAndModule($environmentType$module): Array
  679.     {
  680.         $secrets = [];
  681.         foreach($this->secrets AS $secret) {
  682.             if($secret->getEnvironmentType() == $environmentType && $secret->getModule() == $module) {
  683.                 $secrets[] = $secret;
  684.             }
  685.         }
  686.         return $secrets;
  687.     }
  688.     public function addSecret(Secret $secret): self
  689.     {
  690.         if (!$this->secrets->contains($secret)) {
  691.             $this->secrets[] = $secret;
  692.             $secret->setProject($this);
  693.         }
  694.         return $this;
  695.     }
  696.     public function removeSecret(Secret $secret): self
  697.     {
  698.         if ($this->secrets->removeElement($secret)) {
  699.             // set the owning side to null (unless already changed)
  700.             if ($secret->getProject() === $this) {
  701.                 $secret->setProject(null);
  702.             }
  703.         }
  704.         return $this;
  705.     }
  706. }