コード例 #1
0
 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);
 }
コード例 #2
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());
 }