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.         public function getId(): ?string
  73.         {
  74.             return $this->id;
  75.         }
  76.         public function getSlug(): ?string
  77.         {
  78.             return $this->slug;
  79.         }
  80.         public function setSlug(string $slug): static
  81.         {
  82.             $this->slug $slug;
  83.             return $this;
  84.         }
  85.         public function getValue(): ?string
  86.         {
  87.             return $this->value;
  88.         }
  89.         public function setValue(?string $value): static
  90.         {
  91.             $this->value $value;
  92.             return $this;
  93.         }
  94.         public function isMaintenance(): ?bool
  95.         {
  96.             return $this->maintenance;
  97.         }
  98.         public function setMaintenance(bool $maintenance): static
  99.         {
  100.             $this->maintenance $maintenance;
  101.             return $this;
  102.         }
  103.         public function isUav(): ?bool
  104.         {
  105.             return $this->uav;
  106.         }
  107.         public function setUav(bool $uav): static
  108.         {
  109.             $this->uav $uav;
  110.             return $this;
  111.         }
  112.         /**
  113.          * @return Collection<int, Operation>
  114.          */
  115.         public function getOperations(): Collection
  116.         {
  117.             return $this->operations;
  118.         }
  119.         public function addOperation(Operation $operation): static
  120.         {
  121.             if (!$this->operations->contains($operation)) {
  122.                 $this->operations->add($operation);
  123.                 $operation->setGroup($this);
  124.             }
  125.             return $this;
  126.         }
  127.         public function removeOperation(Operation $operation): static
  128.         {
  129.             if ($this->operations->removeElement($operation)) {
  130.                 // set the owning side to null (unless already changed)
  131.                 if ($operation->getGroup() === $this) {
  132.                     $operation->setGroup(null);
  133.                 }
  134.             }
  135.             return $this;
  136.         }
  137.         /**
  138.          * @return Collection<int, InterventionActivityType>
  139.          */
  140.         public function getActivityTypes(): Collection
  141.         {
  142.             return $this->activityTypes;
  143.         }
  144.         public function addActivityType(InterventionActivityType $activityType): static
  145.         {
  146.             if (!$this->activityTypes->contains($activityType)) {
  147.                 $this->activityTypes->add($activityType);
  148.                 $activityType->addOperationGroup($this);
  149.             }
  150.             return $this;
  151.         }
  152.         public function removeActivityType(InterventionActivityType $activityType): static
  153.         {
  154.             if ($this->activityTypes->removeElement($activityType)) {
  155.                 $activityType->removeOperationGroup($this);
  156.             }
  157.             return $this;
  158.         }
  159. }