本文整理汇总了PHP中Symfony\Component\Routing\Route::getOption方法的典型用法代码示例。如果您正苦于以下问题:PHP Route::getOption方法的具体用法?PHP Route::getOption怎么用?PHP Route::getOption使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Routing\Route
的用法示例。
在下文中一共展示了Route::getOption方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: access
/**
* {@inheritdoc}
*/
public function access(Route $route, AccountInterface $account, RdfInterface $rdf_entity, $operation = 'view')
{
$graph = $route->getOption('graph_name');
$entity_type_id = $route->getOption('entity_type_id');
$storage = $this->entityManager->getStorage($entity_type_id);
if (!$storage instanceof RdfEntitySparqlStorage) {
throw new \Exception('Storage not supported.');
}
// The active graph is the published graph. It is handled by the default
// operation handler.
// @todo: getActiveGraph is not the default. We should load from settings.
$default_graph = $storage->getBundleGraphUri($rdf_entity->bundle(), 'default');
$requested_graph = $storage->getBundleGraphUri($rdf_entity->bundle(), $graph);
if ($requested_graph == $default_graph) {
return AccessResult::neutral();
}
$active_graph_type = $storage->getRequestGraphs($rdf_entity->id());
// Check if there is an entity saved in the passed graph.
$storage->setRequestGraphs($rdf_entity->id(), [$graph]);
$entity = $storage->load($rdf_entity->id());
// Restore active graph.
$storage->setRequestGraphs($rdf_entity->id(), $active_graph_type);
// @todo: When the requested graph is the only one and it is not the
// default, it is loaded in the default view, so maybe there is no need
// to also show a separate tab.
return AccessResult::allowedIf($entity && $this->checkAccess($rdf_entity, $route, $account, $operation, $graph))->cachePerPermissions()->addCacheableDependency($rdf_entity);
}
示例2: generateI18nPatterns
/**
* {@inheritDoc}
*/
public function generateI18nPatterns($routeName, Route $route)
{
$patterns = array();
foreach ($route->getOption('i18n_locales') ?: $this->locales as $locale) {
// Check if translation exists in the translation catalogue to avoid errors being logged by
// the new LoggingTranslator of Symfony 2.6. However, the LoggingTranslator did not implement
// the interface until Symfony 2.6.5, so an extra check is needed.
if ($this->translator instanceof TranslatorBagInterface || $this->translator instanceof LoggingTranslator) {
// Check if route is translated.
if (!$this->translator->getCatalogue($locale)->has($routeName, $this->translationDomain)) {
// No translation found.
$i18nPattern = $route->getPattern();
} else {
// Get translation.
$i18nPattern = $this->translator->trans($routeName, array(), $this->translationDomain, $locale);
}
} else {
// if no translation exists, we use the current pattern
if ($routeName === ($i18nPattern = $this->translator->trans($routeName, array(), $this->translationDomain, $locale))) {
$i18nPattern = $route->getPattern();
}
}
// prefix with locale if requested
if (self::STRATEGY_PREFIX === $this->strategy || self::STRATEGY_PREFIX_EXCEPT_DEFAULT === $this->strategy && $this->defaultLocale !== $locale) {
$i18nPattern = '/' . $locale . $i18nPattern;
if (null !== $route->getOption('i18n_prefix')) {
$i18nPattern = $route->getOption('i18n_prefix') . $i18nPattern;
}
}
$patterns[$i18nPattern][] = $locale;
}
return $patterns;
}
示例3: shouldExcludeRoute
/**
* {@inheritdoc}
*/
public function shouldExcludeRoute($routeName, Route $route)
{
if ('_' === $routeName[0]) {
return true;
}
if (false === $route->getOption('i18n') || 'false' === $route->getOption('i18n')) {
return true;
}
return false;
}
示例4: generateI18nPatterns
/**
* {@inheritDoc}
*/
public function generateI18nPatterns($routeName, Route $route)
{
$patterns = array();
foreach ($route->getOption('i18n_locales') ?: $this->locales as $locale) {
// Check if translation exists in the translation catalogue to avoid errors being logged by
// the new LoggingTranslator of Symfony 2.6. However, the LoggingTranslator did not implement
// the interface until Symfony 2.6.5, so an extra check is needed.
if ($this->translator instanceof TranslatorBagInterface || $this->translator instanceof LoggingTranslator) {
// Check if route is translated.
if (!$this->translator->getCatalogue($locale)->has($routeName, $this->translationDomain)) {
// No translation found.
$i18nPattern = $route->getPath();
} else {
// Get translation.
$i18nPattern = $this->translator->trans($routeName, array(), $this->translationDomain, $locale);
}
} else {
// if no translation exists, we use the current pattern
if ($routeName === ($i18nPattern = $this->translator->trans($routeName, array(), $this->translationDomain, $locale))) {
$i18nPattern = $route->getPath();
}
}
///////////////////////////////////////
// Begin customizations
// prefix with zikula module url if requested
if ($route->hasDefault('_zkModule')) {
$module = $route->getDefault('_zkModule');
$zkNoBundlePrefix = $route->getOption('zkNoBundlePrefix');
if (!isset($zkNoBundlePrefix) || !$zkNoBundlePrefix) {
$untranslatedPrefix = $this->getModUrlString($module);
if ($this->translator->getCatalogue($locale)->has($untranslatedPrefix, strtolower($module))) {
$prefix = $this->translator->trans($untranslatedPrefix, [], strtolower($module), $locale);
} else {
$prefix = $untranslatedPrefix;
}
$i18nPattern = "/" . $prefix . $i18nPattern;
}
}
// End customizations
///////////////////////////////////////
// prefix with locale if requested
if (self::STRATEGY_PREFIX === $this->strategy || self::STRATEGY_PREFIX_EXCEPT_DEFAULT === $this->strategy && $this->defaultLocale !== $locale) {
$i18nPattern = '/' . $locale . $i18nPattern;
if (null !== $route->getOption('i18n_prefix')) {
$i18nPattern = $route->getOption('i18n_prefix') . $i18nPattern;
}
}
$patterns[$i18nPattern][] = $locale;
}
return $patterns;
}
示例5: publicToPrivateWriterForward
public function publicToPrivateWriterForward(Route $currentRoute, array $attributes, Request $currentRequest)
{
$attributes['_controller'] = $this->router->getRouteCollection()->get($currentRoute->getOption('forward_http_route'))->getDefault('_controller');
$subRequest = $currentRequest->duplicate(null, null, $attributes);
$response = $this->kernel->handle($subRequest, HttpKernelInterface::SUB_REQUEST);
return $response;
}
示例6: processRoute
/**
* {@inheritdoc}
*/
protected function processRoute(Route $route)
{
// Add entity upcasting information.
$parameters = $route->getOption('parameters') ?: array();
$parameters += array('menu_link_plugin' => array('type' => 'menu_link_plugin'));
$route->setOption('parameters', $parameters);
}
示例7: resolve
/**
* {@inheritdoc}
*/
public function resolve(Route $route, RouteCollectionAccessor $routes)
{
if ($route->getOption('group') !== self::ROUTE_GROUP) {
return;
}
if ($this->hasAttribute($route, self::ACTIVITY_PLACEHOLDER)) {
$activities = array_map(function (ConfigInterface $config) {
// convert to entity alias
return $this->entityAliasResolver->getPluralAlias($config->getId()->getClassName());
}, $this->groupingConfigProvider->filter(function (ConfigInterface $config) {
// filter activity entities
$groups = $config->get('groups');
return !empty($groups) && in_array(ActivityScope::GROUP_ACTIVITY, $groups, true);
}));
if (!empty($activities)) {
$activities = $this->adjustRoutes($route, $routes, $activities);
if (!empty($activities)) {
$route->setRequirement(self::ACTIVITY_ATTRIBUTE, implode('|', $activities));
}
}
$this->completeRouteRequirements($route);
} elseif ($this->hasAttribute($route, self::ENTITY_PLACEHOLDER)) {
$this->completeRouteRequirements($route);
}
}
示例8: handle
/**
* {@inheritdoc}
*/
public function handle(ApiDoc $annotation, array $annotations, Route $route, \ReflectionMethod $method)
{
if ($route->getOption('group') !== RestRouteOptionsResolver::ROUTE_GROUP) {
return;
}
$action = $route->getDefault('_action');
if (empty($action)) {
return;
}
$entityClass = $this->getEntityClass($route);
if ($entityClass) {
$config = $this->getConfig($action, $entityClass);
$this->setDescription($annotation, $action, (array) $config->getConfig(), $entityClass);
if ($this->hasAttribute($route, RestRouteOptionsResolver::ID_PLACEHOLDER)) {
$this->addIdRequirement($annotation, $entityClass, $route->getRequirement(RestRouteOptionsResolver::ID_ATTRIBUTE));
}
if ($config->hasConfigExtra(FiltersConfigExtra::NAME) && method_exists($config, 'getFilters')) {
$this->addFilters($annotation, $config->getFilters());
}
}
$formatRequirement = $route->getRequirement(RestRouteOptionsResolver::FORMAT_ATTRIBUTE);
if ($formatRequirement) {
$this->addFormatRequirement($annotation, $formatRequirement);
}
}
示例9: testConstructor
public function testConstructor()
{
$route = new Route('/{foo}', array('foo' => 'bar'), array('foo' => '\\d+'), array('foo' => 'bar'));
$this->assertEquals('/{foo}', $route->getPattern(), '__construct() takes a pattern as its first argument');
$this->assertEquals(array('foo' => 'bar'), $route->getDefaults(), '__construct() takes defaults as its second argument');
$this->assertEquals(array('foo' => '\\d+'), $route->getRequirements(), '__construct() takes requirements as its third argument');
$this->assertEquals('bar', $route->getOption('foo'), '__construct() takes options as its fourth argument');
}
示例10: handle
/**
* {@inheritdoc}
*/
public function handle(ApiDoc $annotation, array $annotations, Route $route, \ReflectionMethod $method)
{
if (!$route->getOption('old_options')) {
return;
}
$annotation->setDeprecated(true);
$annotation->setDocumentation($annotation->getDocumentation() . "\n\nDeprecated since v1.8. Will be removed in v2.0");
}
示例11: loadEntity
/**
* Returns the default revision of the entity this route is for.
*
* @param \Symfony\Component\Routing\Route $route
* The route to check against.
* @param \Drupal\Core\Routing\RouteMatchInterface $route_match
* The parametrized route.
*
* @return \Drupal\Core\Entity\ContentEntityInterface
* returns the Entity in question.
*
* @throws \Exception
* A generic exception is thrown if the entity couldn't be loaded. This
* almost always implies a developer error, so it should get turned into
* an HTTP 500.
*/
protected function loadEntity(Route $route, RouteMatchInterface $route_match)
{
$entity_type = $route->getOption('_content_moderation_entity_type');
if ($entity = $route_match->getParameter($entity_type)) {
if ($entity instanceof EntityInterface) {
return $entity;
}
}
throw new \Exception(sprintf('%s is not a valid entity route. The LatestRevisionCheck access checker may only be used with a route that has a single entity parameter.', $route_match->getRouteName()));
}
示例12: generateI18nPatterns
/**
* {@inheritDoc}
*/
public function generateI18nPatterns($routeName, Route $route)
{
$patterns = array();
foreach ($route->getOption('i18n_locales') ?: $this->locales as $locale) {
// if no translation exists, we use the current pattern
if ($routeName === ($i18nPattern = $this->translator->trans($routeName, array(), $this->translationDomain, $locale))) {
$i18nPattern = $route->getPattern();
}
// prefix with locale if requested
if (self::STRATEGY_PREFIX === $this->strategy || self::STRATEGY_PREFIX_EXCEPT_DEFAULT === $this->strategy && $this->defaultLocale !== $locale) {
$i18nPattern = '/' . $locale . $i18nPattern;
if (null !== $route->getOption('i18n_prefix')) {
$i18nPattern = $route->getOption('i18n_prefix') . $i18nPattern;
}
}
$patterns[$i18nPattern][] = $locale;
}
return $patterns;
}
示例13: applies
/**
* {@inheritdoc}
*/
public function applies(Route $route)
{
// Check whether there is any entity revision parameter.
$parameters = $route->getOption('parameters') ?: [];
foreach ($parameters as $info) {
if (isset($info['type']) && strpos($info['type'], 'entity_revision:') === 0) {
return TRUE;
}
}
return FALSE;
}
示例14: generateI18nPatterns
public function generateI18nPatterns($routeName, Route $route)
{
$patterns = array();
$config = $route->getOption('i18n');
foreach ($this->locales as $locale) {
// if no translation exists, we use the current pattern
$i18nPattern = array_key_exists($locale, $config) ? $config[$locale] : $route->getPath();
$i18nPattern = '/' . $locale . $i18nPattern;
$patterns[$i18nPattern][] = $locale;
}
return $patterns;
}
示例15: 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]);
}
}
}
}