本文整理汇总了PHP中Symfony\Component\Routing\Route::hasOption方法的典型用法代码示例。如果您正苦于以下问题:PHP Route::hasOption方法的具体用法?PHP Route::hasOption怎么用?PHP Route::hasOption使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Routing\Route
的用法示例。
在下文中一共展示了Route::hasOption方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: shouldExcludeRoute
public function shouldExcludeRoute($routeName, Route $route)
{
if ('_' === $routeName[0] || !$route->hasOption('i18n')) {
return true;
}
return false;
}
示例2: testOption
public function testOption()
{
$route = new Route('/{foo}');
$this->assertFalse($route->hasOption('foo'), '->hasOption() return false if option is not set');
$this->assertEquals($route, $route->setOption('foo', 'bar'), '->setOption() implements a fluent interface');
$this->assertEquals('bar', $route->getOption('foo'), '->setOption() sets the option');
$this->assertTrue($route->hasOption('foo'), '->hasOption() return true if option is set');
}
示例3: processOutbound
/**
* {@inheritdoc}
*/
public function processOutbound($route_name, Route $route, array &$parameters, BubbleableMetadata $bubbleable_metadata = NULL)
{
if ($route->hasOption('parameters')) {
foreach ($route->getOption('parameters') as $type => $parameter) {
// If the rdf_entity converter exists in the parameter,
// then the parameter is of type rdf_entity and needs to be normalized.
if (isset($parameter['converter']) && $parameter['converter'] == 'paramconverter.rdf_entity') {
$parameters[$type] = str_replace('/', '\\', $parameters[$type]);
}
}
}
}
示例4: getTokenFromRoute
/**
* @param Route $route
* @return CsrfToken|null
*/
public function getTokenFromRoute(Route $route)
{
// Check if route has the option
if (!$route->hasOption(self::OPTION_NAME)) {
return null;
}
// Get option
$option = $route->getOption(self::OPTION_NAME);
if (!$option) {
return null;
}
// Get token
return $this->getTokenFromOption($option);
}
示例5: processRequest
/**
* {@inheritdoc}
*/
public function processRequest(Request $request, Route $route)
{
$givenToken = $request->headers->get(self::HEADER);
$session = $request->getSession();
$expectedToken = $session->get(self::CSRF);
if ($request->isMethod('GET') && !$route->hasOption(self::CSRF) || $route->hasDefault('_guest')) {
if (empty($expectedToken)) {
$this->renewCsrfToken();
}
return;
}
if (empty($givenToken) || $givenToken !== $expectedToken) {
throw new MethodNotAllowedException(['POST'], 'invalid CSRF token');
}
$this->generateNewTokenWhenNeeded($session);
}
示例6: processRequest
/**
* {@inheritdoc}
*/
public function processRequest(Request $request, Route $route)
{
if (!$this->enabled || !$route->hasOption('cache') || !$request->isMethod('GET')) {
return null;
}
$cacheKey = $this->generateCacheKey($request);
$ttl = $route->getOption('cache');
$cache = $this->getCache();
if ($cache->hasItem($cacheKey)) {
return $this->handleCached($cache, $cacheKey, $ttl);
}
// enable cache for current request. Store response later in given key
$request->attributes->set('_cacheKey', $cacheKey);
$request->attributes->set('_cacheTTL', $ttl);
return null;
}
示例7: applies
/**
* {@inheritdoc}
*/
public function applies(Route $route) {
return ($route->hasOption('_scheduled_updates'));
}
示例8: convertRouteToConfig
/**
* @param Route $route
* @return array
*/
private function convertRouteToConfig(Route $route)
{
$className = $route->getOption(self::RESOURCE_ENTITY_CLASS_OPTION);
$converter = $this->defaultConverter;
if ($route->hasOption(self::RESOURCE_CONVERTER_OPTION)) {
$converter = $route->getOption(self::RESOURCE_CONVERTER_OPTION);
}
if ($route->hasOption(self::RESOURCE_SINGULAR_NAME)) {
$singular = $route->getOption(self::RESOURCE_SINGULAR_NAME);
} else {
$classNameParts = explode('\\', $className);
end($classNameParts);
$singular = strtolower(current($classNameParts));
}
if ($route->hasOption(self::RESOURCE_PLURAL_NAME)) {
$plural = $route->getOption(self::RESOURCE_PLURAL_NAME);
} else {
$plural = $this->inflector->pluralize($singular);
}
return ['route' => $route->getDefault('_route'), 'class' => $className, 'converter' => $converter, 'singular_name' => $singular, 'plural_name' => $plural];
}
示例9: applies
/**
* {@inheritdoc}
*/
public function applies(Route $route)
{
return $route->hasOption('_field_ui');
}
示例10: isRouteFrontend
/**
* @param Route $route
* @return bool
*/
protected function isRouteFrontend(Route $route)
{
return $route->hasOption(self::FRONTEND_OPTION) && true === $route->getOption(self::FRONTEND_OPTION);
}