src/Entity/Gos/Uniqskills/Landing/LandingModule.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Gos\Uniqskills\Landing;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. /**
  7.  * LandingModule
  8.  *
  9.  * @ORM\Table(name="landing_module")
  10.  * @ORM\Entity(repositoryClass="App\Repository\Gos\Uniqskills\Landing\LandingModuleRepository")
  11.  */
  12. class LandingModule
  13. {
  14.     /**
  15.      * @var int
  16.      *
  17.      * @ORM\Column(name="id", type="integer")
  18.      * @ORM\Id
  19.      * @ORM\GeneratedValue(strategy="AUTO")
  20.      */
  21.     private $id;
  22.     /**
  23.      * @var int
  24.      *
  25.      * @ORM\Column(name="position", type="integer")
  26.      */
  27.     private $position;
  28.     /**
  29.      * @var bool
  30.      *
  31.      * @ORM\Column(name="is_visible", type="boolean", options={"default":0})
  32.      */
  33.     private $isVisible false;
  34.     /**
  35.      * @var bool
  36.      *
  37.      * @ORM\Column(type="boolean", options={"default":0})
  38.      */
  39.     private $inSecondMenu false;
  40.     /**
  41.      * @ORM\ManyToOne(targetEntity="LandingModuleType", inversedBy="landingModules")
  42.      * @ORM\JoinColumn()
  43.      */
  44.     private $landingModuleType;
  45.     /**
  46.      * @ORM\OneToMany(targetEntity="LandingModuleItem", mappedBy="landingModule", cascade={"persist", "remove"})
  47.      */
  48.     private $landingModuleItems;
  49.     /**
  50.      * @ORM\ManyToOne(targetEntity="Landing", inversedBy="landingModules")
  51.      * @ORM\JoinColumn(nullable=false, onDelete="CASCADE")
  52.      */
  53.     private $landing;
  54.     public function __construct()
  55.     {
  56.         $this->landingModuleItems = new \Doctrine\Common\Collections\ArrayCollection();
  57.     }
  58.     public function __clone()
  59.     {
  60.         if ($this->id)
  61.         {
  62.             $this->setId(null);
  63.             $items = new \Doctrine\Common\Collections\ArrayCollection();
  64.             foreach ($this->landingModuleItems as $landingModuleItem)
  65.             {
  66.                 /** @var LandingModuleItem $itemClone */
  67.                 /** @var LandingModuleItem $landingModuleItem */
  68.                 $itemClone = clone $landingModuleItem;
  69.                 $itemClone->setLandingModule($this);
  70.                 $items->add($itemClone);
  71.             }
  72.             $this->position += 1;
  73.             $this->landingModuleItems = clone $items;
  74.         }
  75.     }
  76.     public function getId(): ?int
  77.     {
  78.         return $this->id;
  79.     }
  80.     public function setId($id): self
  81.     {
  82.         $this->id $id;
  83.         return $this;
  84.     }
  85.     public function getPosition(): ?int
  86.     {
  87.         return $this->position;
  88.     }
  89.     public function setPosition(int $position): self
  90.     {
  91.         $this->position $position;
  92.         return $this;
  93.     }
  94.     public function getInSecondMenu(): ?bool
  95.     {
  96.         return $this->inSecondMenu;
  97.     }
  98.     public function setInSecondMenu(int $inSecondMenu): self
  99.     {
  100.         $this->inSecondMenu $inSecondMenu;
  101.         return $this;
  102.     }
  103.     public function getIsVisible(): ?bool
  104.     {
  105.         return $this->isVisible;
  106.     }
  107.     public function setIsVisible(bool $isVisible): self
  108.     {
  109.         $this->isVisible $isVisible;
  110.         return $this;
  111.     }
  112.     public function getLandingModuleType(): ?LandingModuleType
  113.     {
  114.         return $this->landingModuleType;
  115.     }
  116.     public function setLandingModuleType(?LandingModuleType $landingModuleType): self
  117.     {
  118.         $this->landingModuleType $landingModuleType;
  119.         return $this;
  120.     }
  121.     /**
  122.      * @return Collection|LandingModuleItem[]
  123.      */
  124.     public function getLandingModuleItems(): Collection
  125.     {
  126.         return $this->landingModuleItems;
  127.     }
  128.     public function sortLandingModuleItems(array $sortingArray): self
  129.     {
  130.         /** @var LandingModuleItem $variable  */
  131.         foreach ($sortingArray as $key => $variable)
  132.         {
  133.             /** @var LandingModuleItem $landingModuleItem */
  134.             foreach ($this->landingModuleItems as $landingModuleItem)
  135.             {
  136.                 if ($variable->getVariableName() === $landingModuleItem->getVariableName())
  137.                 {
  138.                     $sortedLandingModuleItems[$key] = $landingModuleItem;
  139.                 }
  140.             }
  141.         }
  142.         $sortedLandingModuleItems = new ArrayCollection($sortedLandingModuleItems);
  143.         $this->landingModuleItems $sortedLandingModuleItems;
  144.         return $this;
  145.     }
  146.     public function addLandingModuleItem(LandingModuleItem $landingModuleItem): self
  147.     {
  148.         if (!$this->landingModuleItems->contains($landingModuleItem)) {
  149.             $this->landingModuleItems[] = $landingModuleItem;
  150.             $landingModuleItem->setLandingModule($this);
  151.         }
  152.         return $this;
  153.     }
  154.     public function removeLandingModuleItem(LandingModuleItem $landingModuleItem): self
  155.     {
  156.         if ($this->landingModuleItems->contains($landingModuleItem)) {
  157.             $this->landingModuleItems->removeElement($landingModuleItem);
  158.             // set the owning side to null (unless already changed)
  159.             if ($landingModuleItem->getLandingModule() === $this) {
  160.                 $landingModuleItem->setLandingModule(null);
  161.             }
  162.         }
  163.         return $this;
  164.     }
  165.     public function getLanding(): ?Landing
  166.     {
  167.         return $this->landing;
  168.     }
  169.     public function setLanding(?Landing $landing): self
  170.     {
  171.         $this->landing $landing;
  172.         return $this;
  173.     }
  174.     /* ****************************** GETTERS & SETTERS ******************************  */
  175. }