當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。