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


PHP Route::hasOption方法代码示例

本文整理汇总了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;
 }
开发者ID:ehibes,项目名称:silexI18nRoutingServiceProvider,代码行数:7,代码来源:I18nControllerCollection.php

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

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

示例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);
 }
开发者ID:fantoine,项目名称:csrf-route-bundle,代码行数:18,代码来源:CsrfTokenManager.php

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

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

示例7: applies

 /**
  * {@inheritdoc}
  */
 public function applies(Route $route) {
   return ($route->hasOption('_scheduled_updates'));
 }
开发者ID:joebachana,项目名称:usatne,代码行数:6,代码来源:FieldUiRouteEnhancer.php

示例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];
 }
开发者ID:ibrows,项目名称:rest-bundle,代码行数:25,代码来源:ResourceTransformer.php

示例9: applies

 /**
  * {@inheritdoc}
  */
 public function applies(Route $route)
 {
     return $route->hasOption('_field_ui');
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:7,代码来源:FieldUiRouteEnhancer.php

示例10: isRouteFrontend

 /**
  * @param Route $route
  * @return bool
  */
 protected function isRouteFrontend(Route $route)
 {
     return $route->hasOption(self::FRONTEND_OPTION) && true === $route->getOption(self::FRONTEND_OPTION);
 }
开发者ID:adam-paterson,项目名称:orocommerce,代码行数:8,代码来源:BreadcrumbManager.php


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