src/Entity/Slave/OperationGroup.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Slave;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\DBAL\Types\Types;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8.  * @ORM\Table(name="eposm_s_operation_group")
  9.  * @ORM\Entity(repositoryClass="App\Repository\Slave\OperationGroupRepository")
  10.  */
  11. class OperationGroup
  12. {
  13.     public function __toString()
  14.     {
  15.         return $this->getValue();
  16.     }
  17.     
  18.     public function getCanDelete(){
  19.         if(sizeof($this->operations) > 0) return false;
  20.         return true;
  21.     }
  22.     public function displayOperations()
  23.     {
  24.         $html '<table class="m_b_none"><tbody>';
  25.         foreach($this->operations as $operation){
  26.             $html.= '<tr><td>'.$operation->getSupplier().' - '.$operation->getValue().'</td></tr>';
  27.         }
  28.         $html.= '</tbody></table>';
  29.         return $html;
  30.     }
  31.     /**
  32.      * @ORM\Column(name="id", type="bigint")
  33.      * @ORM\Id
  34.      * @ORM\GeneratedValue(strategy="AUTO")
  35.      */
  36.     protected $id;
  37.     /**
  38.      * @ORM\Column(name="slug", type="string", length=191)
  39.      */
  40.     protected $slug;
  41.     
  42.     /**
  43.      * @ORM\Column(name="value", type="string", length=191, nullable=true)
  44.      */
  45.     protected $value;
  46.     
  47.     /**
  48.      * @ORM\Column(name="is_maintenance", type="boolean")
  49.      */
  50.     protected $maintenance false;
  51.     
  52.     /**
  53.      * @ORM\Column(name="is_uav", type="boolean")
  54.      */
  55.     protected $uav false;
  56.     // OneToMany
  57.         /**
  58.          * @ORM\OneToMany(targetEntity="App\Entity\Slave\Operation", mappedBy="group")
  59.          */
  60.         private $operations;
  61.     //
  62.     // ManyToMany
  63.         /**
  64.          * @ORM\ManyToMany(targetEntity="App\Entity\Slave\InterventionActivityType", mappedBy="operationGroups")
  65.          */
  66.         private $activityTypes;
  67.         public function __construct()
  68.         {
  69.             $this->operations = new ArrayCollection();
  70.             $this->activityTypes = new ArrayCollection();
  71.         }
  72.     //
  73.     public function getId(): ?string
  74.     {
  75.         return $this->id;
  76.     }
  77.     public function getSlug(): ?string
  78.     {
  79.         return $this->slug;
  80.     }
  81.     public function setSlug(string $slug): static
  82.     {
  83.         $this->slug $slug;
  84.         return $this;
  85.     }
  86.     public function getValue(): ?string
  87.     {
  88.         return $this->value;
  89.     }
  90.     public function setValue(?string $value): static
  91.     {
  92.         $this->value $value;
  93.         return $this;
  94.     }
  95.     public function isMaintenance(): ?bool
  96.     {
  97.         return $this->maintenance;
  98.     }
  99.     public function setMaintenance(bool $maintenance): static
  100.     {
  101.         $this->maintenance $maintenance;
  102.         return $this;
  103.     }
  104.     public function isUav(): ?bool
  105.     {
  106.         return $this->uav;
  107.     }
  108.     public function setUav(bool $uav): static
  109.     {
  110.         $this->uav $uav;
  111.         return $this;
  112.     }
  113.     /**
  114.      * @return Collection<int, Operation>
  115.      */
  116.     public function getOperations(): Collection
  117.     {
  118.         return $this->operations;
  119.     }
  120.     public function addOperation(Operation $operation): static
  121.     {
  122.         if (!$this->operations->contains($operation)) {
  123.             $this->operations->add($operation);
  124.             $operation->setGroup($this);
  125.         }
  126.         return $this;
  127.     }
  128.     public function removeOperation(Operation $operation): static
  129.     {
  130.         if ($this->operations->removeElement($operation)) {
  131.             // set the owning side to null (unless already changed)
  132.             if ($operation->getGroup() === $this) {
  133.                 $operation->setGroup(null);
  134.             }
  135.         }
  136.         return $this;
  137.     }
  138.     /**
  139.      * @return Collection<int, InterventionActivityType>
  140.      */
  141.     public function getActivityTypes(): Collection
  142.     {
  143.         return $this->activityTypes;
  144.     }
  145.     public function addActivityType(InterventionActivityType $activityType): static
  146.     {
  147.         if (!$this->activityTypes->contains($activityType)) {
  148.             $this->activityTypes->add($activityType);
  149.             $activityType->addOperationGroup($this);
  150.         }
  151.         return $this;
  152.     }
  153.     public function removeActivityType(InterventionActivityType $activityType): static
  154.     {
  155.         if ($this->activityTypes->removeElement($activityType)) {
  156.             $activityType->removeOperationGroup($this);
  157.         }
  158.         return $this;
  159.     }
  160. }