src/CmsBundle/Entity/LocaleSwitcher.php line 27

Open in your IDE?
  1. <?php
  2. namespace App\CmsBundle\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. /**
  5.  * @ORM\Entity(
  6.  *     repositoryClass="App\CmsBundle\Repository\LocaleSwitcherRepository"
  7.  * )
  8.  * @ORM\Table(
  9.  *     name="locale_switcher",
  10.  *     uniqueConstraints={
  11.  *          @ORM\UniqueConstraint(name="locale_switcher_uindex", columns={"source_site_id", "source_page_id", "target_site_id", "target_page_id"})
  12.  *      },
  13.  *     indexes={
  14.  *         @ORM\Index(name="locale_switcher_flag_index", columns={"flag"}),
  15.  *         @ORM\Index(name="locale_switcher_source_site_index", columns={"source_site_id"}),
  16.  *         @ORM\Index(name="locale_switcher_target_site_index", columns={"target_site_id"}),
  17.  *         @ORM\Index(name="locale_switcher_source_page_path_index", columns={"source_page_id"}),
  18.  *         @ORM\Index(name="locale_switcher_target_page_path_index", columns={"target_page_id"}),
  19.  *         @ORM\Index(name="locale_switcher_position_index", columns={"position"}),
  20.  *     }
  21.  * )
  22.  * @ORM\HasLifecycleCallbacks()
  23.  */
  24. class LocaleSwitcher
  25. {
  26.     use IdTrait;
  27.     /**
  28.      * @ORM\Column(name="flag", type="string", length=2, nullable=true)
  29.      */
  30.     private ?string $flag 'WW';
  31.     /**
  32.      * @ORM\ManyToOne(targetEntity="App\CmsBundle\Entity\Site")
  33.      * @ORM\JoinColumn(name="source_site_id", referencedColumnName="id", nullable=false, onDelete="CASCADE")
  34.      */
  35.     private Site $sourceSite;
  36.     /**
  37.      * @ORM\ManyToOne(targetEntity="App\CmsBundle\Entity\Page")
  38.      * @ORM\JoinColumn(name="source_page_id", referencedColumnName="id", nullable=false, onDelete="CASCADE")
  39.      */
  40.     private Page $sourcePage;
  41.     /**
  42.      * @ORM\ManyToOne(targetEntity="App\CmsBundle\Entity\Site")
  43.      * @ORM\JoinColumn(name="target_site_id", referencedColumnName="id", nullable=false, onDelete="CASCADE")
  44.      */
  45.     private Site $targetSite;
  46.     /**
  47.      * @ORM\ManyToOne(targetEntity="App\CmsBundle\Entity\Page")
  48.      * @ORM\JoinColumn(name="target_page_id", referencedColumnName="id", nullable=false, onDelete="CASCADE")
  49.      */
  50.     private Page $targetPage;
  51.     /**
  52.      * @ORM\Column(type="integer", nullable=true)
  53.      */
  54.     private ?int $position null;
  55.     /**
  56.      * @ORM\Column(type="string", length=255, nullable=true)
  57.      */
  58.     private ?string $anchor null;
  59.     /**
  60.      * @param string|null $flag
  61.      * @return $this
  62.      */
  63.     public function setFlag(?string $flag): self
  64.     {
  65.         $this->flag $flag;
  66.         return $this;
  67.     }
  68.     /**
  69.      * @return string|null
  70.      */
  71.     public function getFlag(): ?string
  72.     {
  73.         return $this->flag;
  74.     }
  75.     /**
  76.      * @param Site $sourceSite
  77.      * @return $this
  78.      */
  79.     public function setSourceSite(Site $sourceSite): self
  80.     {
  81.         $this->sourceSite $sourceSite;
  82.         return $this;
  83.     }
  84.     /**
  85.      * @return Site|null
  86.      */
  87.     public function getSourceSite(): ?Site
  88.     {
  89.         return $this->sourceSite;
  90.     }
  91.     /**
  92.      * @param Page $sourcePage
  93.      * @return $this
  94.      */
  95.     public function setSourcePage(Page $sourcePage): self
  96.     {
  97.         $this->sourcePage $sourcePage;
  98.         return $this;
  99.     }
  100.     /**
  101.      * @return Page|null
  102.      */
  103.     public function getSourcePage(): ?Page
  104.     {
  105.         return $this->sourcePage;
  106.     }
  107.     /**
  108.      * @param Site $targetSite
  109.      * @return $this
  110.      */
  111.     public function setTargetSite(Site $targetSite): self
  112.     {
  113.         $this->targetSite $targetSite;
  114.         return $this;
  115.     }
  116.     /**
  117.      * @return Site|null
  118.      */
  119.     public function getTargetSite(): ?Site
  120.     {
  121.         return $this->targetSite;
  122.     }
  123.     /**
  124.      * @param Page $targetPage
  125.      * @return $this
  126.      */
  127.     public function setTargetPage(Page $targetPage): self
  128.     {
  129.         $this->targetPage $targetPage;
  130.         return $this;
  131.     }
  132.     /**
  133.      * @return Page|null
  134.      */
  135.     public function getTargetPage(): ?Page
  136.     {
  137.         return $this->targetPage;
  138.     }
  139.     /**
  140.      * @param int|null $position
  141.      * @return $this
  142.      */
  143.     public function setPosition(?int $position): self
  144.     {
  145.         $this->position $position;
  146.         return $this;
  147.     }
  148.     /**
  149.      * @return int|null
  150.      */
  151.     public function getPosition(): ?int
  152.     {
  153.         return $this->position;
  154.     }
  155.     /**
  156.      * @param string|null $anchor
  157.      * @return $this
  158.      */
  159.     public function setAnchor(?string $anchor): self
  160.     {
  161.         $this->anchor $anchor;
  162.         return $this;
  163.     }
  164.     /**
  165.      * @return string|null
  166.      */
  167.     public function getAnchor(): ?string
  168.     {
  169.         return $this->anchor;
  170.     }
  171.     /**
  172.      * @return string|null
  173.      */
  174.     public function getSourcePagePath(): ?string
  175.     {
  176.         return $this->sourcePage?->getPath();
  177.     }
  178.     /**
  179.      * @return string|null
  180.      */
  181.     public function getTargetPagePath(): ?string
  182.     {
  183.         return $this->targetPage?->getPath();
  184.     }
  185.     /**
  186.      * @return int|null
  187.      */
  188.     public function getSourcePageId(): ?int
  189.     {
  190.         return $this->sourcePage?->getId();
  191.     }
  192.     /**
  193.      * @return int|null
  194.      */
  195.     public function getTargetPageId(): ?int
  196.     {
  197.         return $this->targetPage?->getId();
  198.     }
  199. }