Gets the UrlGenerator instance associated with this Router.
public getGenerator ( ) : UrlGeneratorInterface | ||
리턴 | UrlGeneratorInterface | A UrlGeneratorInterface instance |
/** * @param RouterInterface $router */ public function __construct(Router $router) { /** * @var UrlGenerator $urlGenerator */ $urlGenerator = $router->getGenerator(); $this->urlGenerator = $urlGenerator; }
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; }
/** * 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; }
public function __construct(LoggerInterface $logger, Router $router) { $this->logger = $logger; $this->generator = $router->getGenerator(); }
/** * Constructor. * * @param Router $router A Router instance */ public function __construct(Router $router) { $this->generator = $router->getGenerator(); }
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; }
/** * 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(); }
public function __construct(Router $router, $nbPostsPerPage) { $this->generator = $router->getGenerator(); $this->nbPostsPerPage = $nbPostsPerPage; }
public function __construct(Router $router, Request $request) { $this->router = $router; $this->request = $request; $this->generator = $router->getGenerator(); }
public function __construct(PlayerBlamer $playerBlamer, Router $router, Logger $logger) { $this->playerBlamer = $playerBlamer; $this->urlGenerator = $router->getGenerator(); $this->logger = $logger; }