getGenerator() public method

Gets the UrlGenerator instance associated with this Router.
public getGenerator ( ) : UrlGeneratorInterface
return UrlGeneratorInterface A UrlGeneratorInterface instance
Ejemplo n.º 1
0
 /**
  * @param RouterInterface $router
  */
 public function __construct(Router $router)
 {
     /**
      * @var UrlGenerator $urlGenerator
      */
     $urlGenerator = $router->getGenerator();
     $this->urlGenerator = $urlGenerator;
 }
Ejemplo n.º 2
0
 public function __construct(Logger $logger, Messenger $messenger, Generator $generator, Memory $memory, Router $router, DocumentManager $objectManager)
 {
     $this->logger = $logger;
     $this->messenger = $messenger;
     $this->gameGenerator = $generator;
     $this->memory = $memory;
     $this->urlGenerator = $router->getGenerator();
     $this->objectManager = $objectManager;
 }
Ejemplo n.º 3
0
 /**
  * Creates a Node object based on given $routeName or current route.
  *
  * @param string|null $routeName
  *
  * @return Node
  */
 public function createPageFromRoute($routeName = null)
 {
     if (!$routeName) {
         $routeName = $this->pageStack->getRequest()->attributes->get('_route');
         if (!$routeName) {
             throw new \RuntimeException('Could not detect route name');
         }
     }
     $reflection = new \ReflectionClass($this->router->getGenerator());
     $key = 'jarves_routes';
     $cache = $this->cacher->getFastCache($key);
     $validCache = false;
     $routes = [];
     if ($cache) {
         $validCache = $cache['time'] === filemtime($reflection->getFileName()) && isset($cache['routes']) && is_string($cache['routes']);
         if ($validCache) {
             $routes = unserialize($cache['routes']);
         }
     }
     if (!$validCache) {
         $routes = $this->router->getRouteCollection()->all();
         $this->cacher->setFastCache($key, ['time' => filemtime($reflection->getFileName()), 'routes' => serialize($routes)]);
     }
     if (!isset($routes[$routeName])) {
         throw new \RuntimeException("Route with name `{$routeName}` does not exist");
     }
     $route = $routes[$routeName];
     $url = $this->router->generate($routeName, $this->pageStack->getRequest()->attributes->all());
     $page = Node::createPage($route->getOption('title'), parse_url($url)['path'], $route->getOption('theme'), $route->getOption('layout'));
     if ($route->getOption('meta')) {
         foreach ((array) $route->getOption('meta') as $key => $value) {
             $page->meta->set($key, $value);
         }
     }
     return $page;
 }
Ejemplo n.º 4
0
 public function __construct(LoggerInterface $logger, Router $router)
 {
     $this->logger = $logger;
     $this->generator = $router->getGenerator();
 }
Ejemplo n.º 5
0
 /**
  * Constructor.
  *
  * @param Router $router A Router instance
  */
 public function __construct(Router $router)
 {
     $this->generator = $router->getGenerator();
 }
Ejemplo n.º 6
0
 public function getGenerator()
 {
     return new UrlGeneratorDecorator(parent::getGenerator(), $this->getContext());
 }
 /**
  * Constructor
  *
  * @param Router $router
  * @param string[][] $serializationData
  */
 public function __construct(Router $router, array $serializationData)
 {
     $this->urlGenerator = $router->getGenerator();
     $this->data = $serializationData;
 }
Ejemplo n.º 8
0
 /**
  * Build the URL for the deposit receipt.
  *
  * @param Deposit $deposit
  *
  * @return string
  */
 public function buildDepositReceiptUrl(Deposit $deposit)
 {
     return $this->router->getGenerator()->generate('statement', array('journal_uuid' => $deposit->getJournal()->getUuid(), 'deposit_uuid' => $deposit->getDepositUuid()), UrlGeneratorInterface::ABSOLUTE_URL);
 }
 /**
  * {@inheritdoc}
  */
 public function warmUp($cacheDir)
 {
     $this->router->getMatcher();
     $this->router->getGenerator();
 }
Ejemplo n.º 10
0
 public function __construct(Router $router, $nbPostsPerPage)
 {
     $this->generator = $router->getGenerator();
     $this->nbPostsPerPage = $nbPostsPerPage;
 }
Ejemplo n.º 11
0
 public function __construct(Router $router, Request $request)
 {
     $this->router = $router;
     $this->request = $request;
     $this->generator = $router->getGenerator();
 }
Ejemplo n.º 12
0
 public function __construct(PlayerBlamer $playerBlamer, Router $router, Logger $logger)
 {
     $this->playerBlamer = $playerBlamer;
     $this->urlGenerator = $router->getGenerator();
     $this->logger = $logger;
 }