src/Entity/Routing/Url.php line 30

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Routing;
  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 Symfony\Cmf\Bundle\CoreBundle\Translatable\TranslatableInterface;
  8. use Symfony\Cmf\Component\Routing\RouteReferrersInterface;
  9. use Symfony\Component\Validator\Constraints as Assert;
  10. use WAM\Bundle\BlockBundle\Entity\UrlHasBlocks;
  11. use WAM\Bundle\BlockBundle\Model\AttributableInterface;
  12. use WAM\Bundle\BlockBundle\Model\Traits\AttributableTrait;
  13. use WAM\Bundle\CoreBundle\Entity\Interfaces\IdentifiableInterface;
  14. use WAM\Bundle\CoreBundle\Model\Identifiable;
  15. use WAM\Bundle\CoreBundle\Model\Translatable;
  16. use WAM\Bundle\CoreBundle\Validator\Constraints as wam;
  17. use WAM\Bundle\RoutingBundle\Entity\Interfaces\HostInterface;
  18. use WAM\Bundle\RoutingBundle\Entity\Interfaces\SeoBehaviourInterface;
  19. use WAM\Bundle\RoutingBundle\Entity\Interfaces\UrlInterface;
  20. use WAM\Bundle\RoutingBundle\Entity\Traits\MultiRouteTrait;
  21. /**
  22.  * @ORM\Entity()
  23.  * @UniqueEntity("name")
  24.  * @ORM\Table(name="app_routing_url")
  25.  *
  26.  **/
  27. class Url implements TranslatableInterfaceIdentifiableInterfaceAttributableInterfaceRouteReferrersInterfaceSeoBehaviourInterfaceUrlInterface
  28. {
  29.     use Identifiable;
  30.     use MultiRouteTrait;
  31.     use AttributableTrait;
  32.     use Translatable;
  33.     /**
  34.      * @ORM\Column(type="string", length=50, unique=true)
  35.      * @Assert\NotBlank()
  36.      *
  37.      * @var string
  38.      */
  39.     private ?string $name null;
  40.     /**
  41.      * @ORM\Column(type="string", nullable=true)
  42.      * @wam\ControllerExists()
  43.      *
  44.      * @var string
  45.      */
  46.     private ?string $controller null;
  47.     /**
  48.      * @ORM\Column(type="string", nullable=true)
  49.      * @wam\TemplateExists()
  50.      *
  51.      * @var string
  52.      */
  53.     private ?string $template null;
  54.     /**
  55.      * @ORM\OneToMany(targetEntity="WAM\Bundle\BlockBundle\Entity\UrlHasBlocks", mappedBy="url", orphanRemoval=true, cascade={"persist"})
  56.      * @ORM\OrderBy({"position" = "ASC"})
  57.      */
  58.     protected Collection $urlHasBlocks;
  59.     /**
  60.      * @ORM\ManyToOne(targetEntity="WAM\Bundle\RoutingBundle\Entity\Host")
  61.      **/
  62.     private ?Host $host null;
  63.     public function __construct()
  64.     {
  65.         $this->urlHasBlocks = new ArrayCollection();
  66.     }
  67.     /**
  68.      * @return string
  69.      */
  70.     public function getName(): ?string
  71.     {
  72.         return $this->name;
  73.     }
  74.     /**
  75.      * @param string $name
  76.      * @return Url
  77.      */
  78.     public function setName(string $name): self
  79.     {
  80.         $this->name $name;
  81.         return $this;
  82.     }
  83.     /**
  84.      * @return string
  85.      */
  86.     public function getController(): ?string
  87.     {
  88.         return $this->controller;
  89.     }
  90.     /**
  91.      * @param string $controller
  92.      * @return Url
  93.      */
  94.     public function setController(?string $controller): self
  95.     {
  96.         $this->controller $controller;
  97.         return $this;
  98.     }
  99.     /**
  100.      * @return string
  101.      */
  102.     public function getTemplate(): ?string
  103.     {
  104.         return $this->template;
  105.     }
  106.     /**
  107.      * @param string $template
  108.      * @return Url
  109.      */
  110.     public function setTemplate(?string $template): self
  111.     {
  112.         $this->template $template;
  113.         return $this;
  114.     }
  115.     /**
  116.      * @return ArrayCollection|Collection
  117.      */
  118.     public function getUrlHasBlocks(): Collection
  119.     {
  120.         return $this->urlHasBlocks;
  121.     }
  122.     /**
  123.      * @param ArrayCollection|Collection $urlHasBlocks
  124.      * @return Url
  125.      */
  126.     public function setUrlHasBlocks(Collection $urlHasBlocks): self
  127.     {
  128.         $this->urlHasBlocks $urlHasBlocks;
  129.         return $this;
  130.     }
  131.     public function getPath(): string
  132.     {
  133.         return $this->translate(nullfalse)->getPath();
  134.     }
  135.     public function setPath(string $path): self
  136.     {
  137.         $this->translate(nullfalse)->setPath($path);
  138.         return $this;
  139.     }
  140.     public function addUrlHasBlocks(UrlHasBlocks $urlHasBlocks): self
  141.     {
  142.         if (!$this->urlHasBlocks->contains($urlHasBlocks)) {
  143.             $this->urlHasBlocks->add($urlHasBlocks);
  144.         }
  145.         return $this;
  146.     }
  147.     /**
  148.      * @return Host|null
  149.      */
  150.     public function getHost(): ?HostInterface
  151.     {
  152.         return $this->host;
  153.     }
  154.     /**
  155.      * @param Host|null $host
  156.      * @return Url
  157.      */
  158.     public function setHost(HostInterface $host): self
  159.     {
  160.         $this->host $host;
  161.         return $this;
  162.     }
  163.     public function __toString()
  164.     {
  165.         return (string) $this->getName();
  166.     }
  167. }