当前位置: 首页>>代码示例>>PHP>>正文


PHP Route::getOption方法代码示例

本文整理汇总了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);
 }
开发者ID:ec-europa,项目名称:joinup-dev,代码行数:30,代码来源:RdfGraphAccessCheck.php

示例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;
 }
开发者ID:normandydeck1,项目名称:JMSI18nRoutingBundle,代码行数:36,代码来源:DefaultPatternGenerationStrategy.php

示例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;
 }
开发者ID:sfblaauw,项目名称:pulsar-i18n-routing,代码行数:13,代码来源:DefaultRouteExclusionStrategy.php

示例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;
 }
开发者ID:Silwereth,项目名称:core,代码行数:54,代码来源:ZikulaPatternGenerationStrategy.php

示例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;
 }
开发者ID:xGouley,项目名称:PSPublicWriterBundle,代码行数:7,代码来源:LocalhostForwarder.php

示例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);
 }
开发者ID:robertfoleyjr,项目名称:robertfoleyjr-d8,代码行数:10,代码来源:MenuLinkConfigMapper.php

示例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);
     }
 }
开发者ID:northdakota,项目名称:platform,代码行数:28,代码来源:ActivityAssociationRouteOptionsResolver.php

示例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);
     }
 }
开发者ID:Maksold,项目名称:platform,代码行数:28,代码来源:RestDocHandler.php

示例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');
 }
开发者ID:laubosslink,项目名称:lab,代码行数:8,代码来源:RouteTest.php

示例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");
 }
开发者ID:Maksold,项目名称:platform,代码行数:11,代码来源:OldOptionsApiDocHandler.php

示例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()));
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:26,代码来源:LatestRevisionCheck.php

示例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;
 }
开发者ID:andrzejdziekonski,项目名称:JMSI18nRoutingBundle,代码行数:22,代码来源:DefaultPatternGenerationStrategy.php

示例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;
 }
开发者ID:heddn,项目名称:content_entity_base,代码行数:14,代码来源:EntityRevisionRouteEnhancer.php

示例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;
 }
开发者ID:ehibes,项目名称:silexI18nRoutingServiceProvider,代码行数:12,代码来源:I18nControllerCollection.php

示例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]);
             }
         }
     }
 }
开发者ID:ec-europa,项目名称:joinup-dev,代码行数:15,代码来源:RouteProcessorRdf.php


注:本文中的Symfony\Component\Routing\Route::getOption方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。