public function it_should_set_template_name_from_route_with_content(RouteInterface $route, ArticleInterface $article)
 {
     $route->getTemplateName()->willReturn('test.html.twig');
     $route->getContent()->willReturn($article);
     $article->getRoute()->willReturn(null);
     $article->getTemplateName()->willReturn(null);
     $this->setTemplateName($article, [RouteObjectInterface::ROUTE_OBJECT => $route])->shouldReturn([RouteObjectInterface::ROUTE_OBJECT => $route, RouteObjectInterface::TEMPLATE_NAME => 'article.html.twig']);
 }
 /**
  * @param RouteInterface $route
  *
  * @return bool
  */
 private function getTemplateNameFromRouteContent(RouteInterface $route)
 {
     if (null !== $route->getContent()) {
         if (null !== ($templateName = $route->getContent()->getTemplateName())) {
             return $templateName;
         }
     }
     return false;
 }
 /**
  * Transforms an object (route) to a string (id).
  *
  * @param RouteInterface|string $route
  *
  * @return string
  *
  * @throws TransformationFailedException if object (route) is of wrong type
  */
 public function transform($route)
 {
     if (null === $route) {
         return;
     }
     if ($route instanceof RouteInterface || $route instanceof Generic) {
         return $route->getId();
     }
     throw new TransformationFailedException(sprintf('"%s" should be of type %s or %s!', get_class($route), RouteInterface::class, Generic::class));
 }
 /**
  * Transforms an object (route) to a string (id).
  *
  * @param RouteInterface|string $route
  *
  * @return string
  *
  * @throws TransformationFailedException if object (route) is of wrong type
  */
 public function transform($route)
 {
     if (null === $route) {
         return;
     }
     if (!$route instanceof RouteInterface) {
         throw new UnexpectedTypeException($route, RouteInterface::class);
     }
     return $route->getId();
 }
 public function it_should_update_existing_route(RouteInterface $route, EventDispatcherInterface $eventDispatcher, RouteInterface $parent)
 {
     $route->getType()->willReturn(RouteInterface::TYPE_COLLECTION);
     $route->getParent()->willReturn($parent);
     $route->getName()->willReturn('test-name');
     $eventDispatcher->dispatch(RouteEvents::PRE_UPDATE, Argument::type(RouteEvent::class))->shouldBeCalled();
     $route->setVariablePattern(Argument::exact('/{slug}'))->shouldBeCalled();
     $route->setRequirement(Argument::exact('slug'), Argument::exact('[a-zA-Z0-9*\\-_\\/]+'))->shouldBeCalled();
     $route->setDefault('slug', null)->shouldBeCalled();
     $route->setStaticPrefix('/test-name')->shouldBeCalled();
     $eventDispatcher->dispatch(RouteEvents::POST_UPDATE, Argument::type(RouteEvent::class))->shouldBeCalled();
     $this->updateRoute($route)->shouldReturn($route);
 }
 public function it_should_transform_route_to_id(RouteInterface $route)
 {
     $route->getId()->willReturn('/some/path/id');
     $this->transform($route)->shouldReturn('/some/path/id');
 }
Esempio n. 7
0
 /**
  * @param RouteInterface $route
  *
  * @return string
  */
 protected function generatePath(RouteInterface $route)
 {
     if (null === ($parent = $route->getParent())) {
         return '/' . $route->getName();
     }
     return sprintf('%s/%s', $parent->getStaticPrefix(), $route->getName());
 }