lib/boab/cms-bundle/src/Entity/Route.php line 16

Open in your IDE?
  1. <?php
  2. namespace Boab\CmsBundle\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Orm\Route as BaseRoute;
  5. /**
  6.  * @ORM\Entity (repositoryClass="Boab\CmsBundle\Repository\RouteRepository")
  7.  * @ORM\Table(name="route")
  8.  * @ORM\InheritanceType("SINGLE_TABLE")
  9.  * @ORM\DiscriminatorColumn(name="route_type", type="string")
  10.  * @ORM\DiscriminatorMap({"list"="ListRoute", "post"="PostRoute", "page"="PageRoute", "taxon"="TermRoute", "url"="UrlRoute"     })
  11.  */
  12. abstract class Route extends BaseRoute implements RouteInterface
  13. {
  14.     const VISIBILITY_OFF 0;
  15.     const VISIBILITY_ON 1;
  16.     const ROUTE_PREFIX 'route_';
  17.     /**
  18.      * @var integer
  19.      *
  20.      * @ORM\Column(name="id", type="integer", precision=0, scale=0, nullable=false, unique=false)
  21.      * @ORM\Id
  22.      * @ORM\GeneratedValue(strategy="IDENTITY")
  23.      */
  24.     protected $id;
  25.     /**
  26.      * @var string
  27.      *
  28.      * @ORM\Column(name="title", type="string", length=255, precision=0, scale=0, nullable=false, unique=false)
  29.      */
  30.     protected $title;
  31.     /**
  32.      * @var string
  33.      *
  34.      * @ORM\Column(name="slug", type="string", length=255, precision=0, scale=0, nullable=false, unique=false)
  35.      */
  36.     protected $slug;
  37.     /**
  38.      * @var string
  39.      *
  40.      * @ORM\Column(name="path", type="string", length=255, precision=0, scale=0, nullable=false, unique=false)
  41.      */
  42.    protected $path;
  43.     /**
  44.      * @var integer
  45.      *
  46.      * @ORM\Column(name="position", type="integer", precision=0, scale=0, nullable=true, unique=false)
  47.      */
  48.     protected int $position 0;
  49.     /**
  50.      * @var \DateTime
  51.      *
  52.      * @ORM\Column(name="date_created", type="datetime", precision=0, scale=0, nullable=false, unique=false)
  53.      */
  54.     protected $dateCreated;
  55.     /**
  56.      * @var integer
  57.      *
  58.      * @ORM\Column(name="visibility", type="boolean")
  59.      */
  60.     protected $visibility;
  61.     /**
  62.      * @var integer
  63.      *
  64.      * @ORM\Column(name="parent_id", type="integer", precision=0, scale=0, nullable=true, unique=false)
  65.      */
  66.     protected $parentId;
  67.     /**
  68.      * @var string
  69.      *
  70.      * @ORM\Column(name="route_name", type="string", length=255, precision=0, scale=0, nullable=true, unique=true)
  71.      */
  72.     protected $routeName;
  73.     /**
  74.      * @var string
  75.      *
  76.      * @ORM\Column(name="template", type="string", length=255, precision=0, scale=0, nullable=true, unique=false)
  77.      */
  78.     protected $template;
  79.     /**
  80.      * @var integer
  81.      *
  82.      * @ORM\Column(name="layout_type", type="integer", length=2, precision=0, scale=0, nullable=true, unique=false)
  83.      */
  84.     protected $layoutType;
  85.     /**
  86.      * use for parent child heirracy
  87.      */
  88.     protected $children = []      ;
  89.     /**
  90.      * Get id
  91.      *
  92.      * @return integer
  93.      */
  94.     public function getId():string
  95.     {
  96.         return $this->id;
  97.     }
  98.     /**
  99.      * Set title
  100.      *
  101.      * @param string $title
  102.      * @return Menu
  103.      */
  104.     public function setTitle($title)
  105.     {
  106.         $this->title $title;
  107.         return $this;
  108.     }
  109.     /**
  110.      * Get title
  111.      *
  112.      * @return string
  113.      */
  114.     public function getTitle(): ?string
  115.     {
  116.         return $this->title;
  117.     }
  118.     /**
  119.      * Set path
  120.      *
  121.      * @param string $path
  122.      * @return Menu
  123.      */
  124.     public function setPath(string $path): static
  125.     {
  126.         $this->path $path;
  127.         return $this;
  128.     }
  129.     /**
  130.      * Get path
  131.      *
  132.      * @return string
  133.      */
  134.     public function getPath():string
  135.     {
  136.         return $this->path;
  137.     }
  138.     /**
  139.      * Set slug
  140.      *
  141.      * @param string $slug
  142.      * @return Menu
  143.      */
  144.     public function setSlug($slug)
  145.     {
  146.         $this->slug $slug;
  147.         return $this;
  148.     }
  149.     /**
  150.      * Get slug
  151.      *
  152.      * @return string
  153.      */
  154.     public function getSlug()
  155.     {
  156.         return $this->slug;
  157.     }
  158.     /**
  159.      * Set dateCreated
  160.      *
  161.      * @param \DateTime $dateCreated
  162.      * @return Menu
  163.      */
  164.     public function setDateCreated($dateCreated)
  165.     {
  166.         $this->dateCreated $dateCreated;
  167.         return $this;
  168.     }
  169.     /**
  170.      * Get dateCreated
  171.      *
  172.      * @return \DateTime
  173.      */
  174.     public function getDateCreated()
  175.     {
  176.         return $this->dateCreated;
  177.     }
  178.     /**
  179.      * Set visibility
  180.      *
  181.      * @param integer $visibility
  182.      * @return Menu
  183.      */
  184.     public function setVisibility($visibility)
  185.     {
  186.         $this->visibility $visibility;
  187.         return $this;
  188.     }
  189.     /**
  190.      * Get visibility
  191.      *
  192.      * @return integer
  193.      */
  194.     public function getVisibility()
  195.     {
  196.         return $this->visibility;
  197.     }
  198.     public function isVisible()
  199.     {
  200.         return (bool)$this->getVisibility();
  201.     }
  202.     /**
  203.      * Set routeName
  204.      *
  205.      * @param string $routeName
  206.      * @return Menu
  207.      */
  208.     public function setRouteName($routeName)
  209.     {
  210.         $this->routeName $routeName;
  211.         return $this;
  212.     }
  213.     /**
  214.      * Get routeName
  215.      *
  216.      * @return string
  217.      */
  218.     public function getRouteName():string
  219.     {
  220.         return (!$this->routeName) ? sprintf('%s%s',self::ROUTE_PREFIX$this->id) : $this->routeName;
  221.     }
  222.     /**
  223.      * Set template
  224.      *
  225.      * @param string $template
  226.      *
  227.      * @return UrlRoute
  228.      */
  229.     public function setTemplate($template)
  230.     {
  231.         $this->template $template;
  232.         return $this;
  233.     }
  234.     /**
  235.      * Get template
  236.      *
  237.      * @return string
  238.      */
  239.     public function getTemplate()
  240.     {
  241.         return $this->template;
  242.     }
  243.     /**
  244.      * Set parentId
  245.      *
  246.      * @param integer $parentId
  247.      *
  248.      * @return Route
  249.      */
  250.     public function setParentId($parent)
  251.     {
  252.         $this->parentId is_object($parent) ? $parent->getId() : $parent;
  253.         return $this;
  254.     }
  255.     /**
  256.      * Get parentId
  257.      *
  258.      * @return integer
  259.      */
  260.     public function getParentId()
  261.     {
  262.         return $this->parentId;
  263.     }
  264.     /**
  265.      * Set layoutType
  266.      *
  267.      * @param integer $layoutType
  268.      *
  269.      * @return Route
  270.      */
  271.     public function setLayoutType($layoutType)
  272.     {
  273.         $this->layoutType $layoutType;
  274.         return $this;
  275.     }
  276.     /**
  277.      * Get layoutType
  278.      *
  279.      * @return integer
  280.      */
  281.     public function getLayoutType():? string
  282.     {
  283.         return $this->layoutType;
  284.     }
  285.     public function setDefaults( array $defauts): static
  286.     {
  287.         $defauts = [
  288.             '_title' => $this->getTitle(),
  289.             '_template'=> $this->getTemplate(),
  290.             '_controller'=>$this->getController(),
  291.         ];
  292.         return parent::setDefaults($defauts);
  293.     }
  294.     public function getRouteKey(): string
  295.     {
  296.         return $this->getRouteName();
  297.     }
  298.     public function hasParent()
  299.     {
  300.         return $this->parentId == null;
  301.     }
  302.     public function hasPath(): bool
  303.     {
  304.         return null !== $this->path;
  305.     }
  306.     public function isParent()
  307.     {
  308.         return == $this->getParentId();
  309.     }
  310.     public function hasParentSelected()
  311.     {
  312.         return (bool)$this->getParentId();
  313.     }
  314.     public function setChildren($children)
  315.     {
  316.         $this->children $children;
  317.     }
  318.     public function getChildren()
  319.     {
  320.         return $this->children;
  321.     }
  322. }