vendor/wearemarketing/routingbundle/Entity/AutoRoute.php line 19

Open in your IDE?
  1. <?php
  2. namespace WAM\Bundle\RoutingBundle\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use Symfony\Cmf\Component\RoutingAuto\Model\AutoRouteInterface as CmfAutoRouteInterface;
  5. use WAM\Bundle\RoutingBundle\Entity\Interfaces\AutoRouteInterface;
  6. use WAM\Bundle\RoutingBundle\Entity\Interfaces\RouteInterface;
  7. /**
  8.  * WAMCMS ORM route.
  9.  *
  10.  * @ORM\Entity()
  11.  *
  12.  * @ORM\EntityListeners({"WAM\Bundle\RoutingBundle\Listener\AutoRouteListener"})
  13.  *
  14.  * @author Noel Garcia <ngarcia@wearemarketing.com>
  15.  */
  16. class AutoRoute extends Route implements CmfAutoRouteInterfaceAutoRouteInterface
  17. {
  18.     const CONTENT_CLASS_KEY 'contentClass';
  19.     const CONTENT_ID_KEY 'contentId';
  20.     /**
  21.      * @ORM\Column(type="string", nullable=true)
  22.      *
  23.      * @var string
  24.      */
  25.     private ?string $contentClass null;
  26.     /**
  27.      * @ORM\Column(type="json_array", nullable=true)
  28.      *
  29.      * @var array
  30.      */
  31.     private array $contentId = [];
  32.     /**
  33.      * @ORM\Column(type="string", nullable=true)
  34.      *
  35.      * @var string
  36.      */
  37.     private ?string $redirectTarget null;
  38.     public function setAutoRouteTag(string $tag): self
  39.     {
  40.         $this->tag $tag;
  41.         return $this;
  42.     }
  43.     /**
  44.      * {@inheritdoc}
  45.      */
  46.     public function setRedirectTarget($autoTarget)
  47.     {
  48.         if ($autoTarget instanceof RouteInterface) {
  49.             $this->redirectTarget $autoTarget->getName();
  50.         } elseif (is_string($autoTarget)) {
  51.             $this->redirectTarget $autoTarget;
  52.         } else {
  53.             throw new \InvalidArgumentException('Redirect target must be string or auto route');
  54.         }
  55.         return $this;
  56.     }
  57.     /**
  58.      * {@inheritdoc}
  59.      */
  60.     public function getRedirectTarget()
  61.     {
  62.         return $this->redirectTarget;
  63.     }
  64.     public function getContentClass(): ?string
  65.     {
  66.         return $this->contentClass;
  67.     }
  68.     public function setContentClass(string $class): self
  69.     {
  70.         $this->contentClass $class;
  71.         return $this;
  72.     }
  73.     public function getContentId(): array
  74.     {
  75.         return $this->contentId;
  76.     }
  77.     public function setContentId(array $id): self
  78.     {
  79.         $this->contentId $id;
  80.         return $this;
  81.     }
  82. }