getGenerator() public method

Gets the UrlGenerator instance associated with this Router.
public getGenerator ( ) : UrlGeneratorInterface
return UrlGeneratorInterface A UrlGeneratorInterface instance
コード例 #1
0
 /**
  * @param RouterInterface $router
  */
 public function __construct(Router $router)
 {
     /**
      * @var UrlGenerator $urlGenerator
      */
     $urlGenerator = $router->getGenerator();
     $this->urlGenerator = $urlGenerator;
 }
コード例 #2
0
ファイル: Rematcher.php プロジェクト: hafeez3000/lichess
 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;
 }
コード例 #3
0
ファイル: PageResponseFactory.php プロジェクト: jarves/jarves
 /**
  * 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;
 }
コード例 #4
0
ファイル: Logger.php プロジェクト: hotfics/lichess-old
 public function __construct(LoggerInterface $logger, Router $router)
 {
     $this->logger = $logger;
     $this->generator = $router->getGenerator();
 }
コード例 #5
0
 /**
  * Constructor.
  *
  * @param Router $router A Router instance
  */
 public function __construct(Router $router)
 {
     $this->generator = $router->getGenerator();
 }
コード例 #6
0
ファイル: Router.php プロジェクト: elfet/silicone
 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;
 }
コード例 #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);
 }
コード例 #9
0
 /**
  * {@inheritdoc}
  */
 public function warmUp($cacheDir)
 {
     $this->router->getMatcher();
     $this->router->getGenerator();
 }
コード例 #10
0
 public function __construct(Router $router, $nbPostsPerPage)
 {
     $this->generator = $router->getGenerator();
     $this->nbPostsPerPage = $nbPostsPerPage;
 }
コード例 #11
0
 public function __construct(Router $router, Request $request)
 {
     $this->router = $router;
     $this->request = $request;
     $this->generator = $router->getGenerator();
 }
コード例 #12
0
ファイル: Joiner.php プロジェクト: hafeez3000/lichess
 public function __construct(PlayerBlamer $playerBlamer, Router $router, Logger $logger)
 {
     $this->playerBlamer = $playerBlamer;
     $this->urlGenerator = $router->getGenerator();
     $this->logger = $logger;
 }