本文整理汇总了PHP中Symfony\Component\Routing\Router::getGenerator方法的典型用法代码示例。如果您正苦于以下问题:PHP Router::getGenerator方法的具体用法?PHP Router::getGenerator怎么用?PHP Router::getGenerator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Routing\Router
的用法示例。
在下文中一共展示了Router::getGenerator方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* @param RouterInterface $router
*/
public function __construct(Router $router)
{
/**
* @var UrlGenerator $urlGenerator
*/
$urlGenerator = $router->getGenerator();
$this->urlGenerator = $urlGenerator;
}
示例2: __construct
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: createPageFromRoute
/**
* 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: __construct
public function __construct(LoggerInterface $logger, Router $router)
{
$this->logger = $logger;
$this->generator = $router->getGenerator();
}
示例5: __construct
/**
* Constructor.
*
* @param Router $router A Router instance
*/
public function __construct(Router $router)
{
$this->generator = $router->getGenerator();
}
示例6: getGenerator
public function getGenerator()
{
return new UrlGeneratorDecorator(parent::getGenerator(), $this->getContext());
}
示例7: __construct
/**
* Constructor
*
* @param Router $router
* @param string[][] $serializationData
*/
public function __construct(Router $router, array $serializationData)
{
$this->urlGenerator = $router->getGenerator();
$this->data = $serializationData;
}
示例8: buildDepositReceiptUrl
/**
* 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: warmUp
/**
* {@inheritdoc}
*/
public function warmUp($cacheDir)
{
$this->router->getMatcher();
$this->router->getGenerator();
}
示例10: __construct
public function __construct(Router $router, $nbPostsPerPage)
{
$this->generator = $router->getGenerator();
$this->nbPostsPerPage = $nbPostsPerPage;
}
示例11: __construct
public function __construct(Router $router, Request $request)
{
$this->router = $router;
$this->request = $request;
$this->generator = $router->getGenerator();
}
示例12: __construct
public function __construct(PlayerBlamer $playerBlamer, Router $router, Logger $logger)
{
$this->playerBlamer = $playerBlamer;
$this->urlGenerator = $router->getGenerator();
$this->logger = $logger;
}