當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Route::addRequirements方法代碼示例

本文整理匯總了PHP中Symfony\Component\Routing\Route::addRequirements方法的典型用法代碼示例。如果您正苦於以下問題:PHP Route::addRequirements方法的具體用法?PHP Route::addRequirements怎麽用?PHP Route::addRequirements使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Symfony\Component\Routing\Route的用法示例。


在下文中一共展示了Route::addRequirements方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: load

 public function load($resource, $type = null)
 {
     if (true === $this->loaded) {
         throw new \RuntimeException('Do not add this loader twice');
     }
     $routes = new RouteCollection();
     $contextConfigLoader = $this->contextConfigLoader;
     foreach ($contextConfigLoader->getRouting() as $routing) {
         foreach ($routing as $id => $info) {
             if (array_key_exists('pattern', $info)) {
                 $route = new Route($info['pattern']);
                 // merge options and defaults
                 if (array_key_exists('defaults', $info)) {
                     $route->addDefaults($info['defaults']);
                 }
                 if (array_key_exists('options', $info)) {
                     $route->addOptions($info['options']);
                 }
                 if (array_key_exists('requirements', $info)) {
                     $route->addRequirements($info['requirements']);
                 }
             }
             $routes->add($id, $route);
         }
     }
     return $routes;
 }
開發者ID:zenmagick,項目名稱:zenmagick,代碼行數:27,代碼來源:ContextLoader.php

示例2: getRevisionRevertRoute

 /**
  * Gets the entity revision revert route.
  *
  * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
  *   The entity type.
  *
  * @return \Symfony\Component\Routing\Route|null
  *   The generated route, if available.
  */
 protected function getRevisionRevertRoute(EntityTypeInterface $entity_type)
 {
     if ($entity_type->hasLinkTemplate('revision-revert-form')) {
         $entity_type_id = $entity_type->id();
         $route = new Route($entity_type->getLinkTemplate('revision-revert-form'));
         $route->addDefaults(['_form' => '\\Drupal\\entity\\Form\\RevisionRevertForm', 'title' => 'Revert to earlier revision']);
         $route->addRequirements(['_entity_access_revision' => "{$entity_type_id}.update"]);
         $route->setOption('parameters', [$entity_type->id() => ['type' => 'entity:' . $entity_type->id()], $entity_type->id() . '_revision' => ['type' => 'entity_revision:' . $entity_type->id()]]);
         return $route;
     }
 }
開發者ID:CIGIHub,項目名稱:bsia-drupal8,代碼行數:20,代碼來源:RevisionRouteProvider.php

示例3: getRevisionViewRoute

 /**
  * Gets the entity revision view route.
  *
  * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
  *   The entity type.
  *
  * @return \Symfony\Component\Routing\Route|null
  *   The generated route, if available.
  */
 protected function getRevisionViewRoute(EntityTypeInterface $entity_type)
 {
     if ($entity_type->hasLinkTemplate('revision')) {
         $entity_type_id = $entity_type->id();
         $route = new Route($entity_type->getLinkTemplate('revision'));
         $route->addDefaults(['_controller' => '\\Drupal\\entity\\Controller\\RevisionController::view', '_title_callback' => '\\Drupal\\Core\\Entity\\Controller\\EntityController::title']);
         $route->addRequirements(['_entity_access_revision' => "{$entity_type_id}.view"]);
         $route->setOption('parameters', [$entity_type->id() => ['type' => 'entity:' . $entity_type->id()], $entity_type->id() . '_revision' => ['type' => 'entity_revision:' . $entity_type->id()]]);
         return $route;
     }
 }
開發者ID:darrylri,項目名稱:protovbmwmo,代碼行數:20,代碼來源:RevisionRouteProvider.php

示例4: route

 /**
  * Add an endpiont/application to the server
  * @param string             $path The URI the client will connect to
  * @param ComponentInterface $controller Your application to server for the route. If not specified, assumed to be for a WebSocket
  * @param array              $allowedOrigins An array of hosts allowed to connect (same host by default), ['*'] for any
  * @param string             $httpHost Override the $httpHost variable provided in the __construct
  * @return ComponentInterface|WsServer
  */
 public function route($path, ComponentInterface $controller, array $allowedOrigins = array(), $httpHost = null)
 {
     if ($controller instanceof HttpServerInterface || $controller instanceof WsServer) {
         $decorated = $controller;
     } elseif ($controller instanceof WampServerInterface) {
         $decorated = new WsServer(new WampServer($controller));
     } elseif ($controller instanceof MessageComponentInterface) {
         $decorated = new WsServer($controller);
     } else {
         $decorated = $controller;
     }
     if ($httpHost === null) {
         $httpHost = $this->httpHost;
     }
     $allowedOrigins = array_values($allowedOrigins);
     if (0 === count($allowedOrigins)) {
         $allowedOrigins[] = $httpHost;
     }
     if ('*' !== $allowedOrigins[0]) {
         $decorated = new OriginCheck($decorated, $allowedOrigins);
     }
     $route = null;
     if ($path instanceof Route) {
         $route = $path;
         $route->setDefault('_controller', $decorated);
     } else {
         $route = new Route($path, array('_controller' => $decorated));
     }
     if ('*' !== $httpHost) {
         $route->addRequirements(array('Origin' => $httpHost));
         $route->setHost($httpHost);
     }
     $this->routes->add('rr-' . ++$this->_routeCounter, $route);
     return $decorated;
 }
開發者ID:Rudi9719,項目名稱:stein-syn,代碼行數:43,代碼來源:App.php

示例5: processRoute

 /**
  * {@inheritdoc}
  */
 public function processRoute(Route $route)
 {
     $route->addRequirements(array('_access' => 'TRUE'));
 }
開發者ID:Jbartsch,項目名稱:travelbruh-api,代碼行數:7,代碼來源:ServiceDefinitionBase.php

示例6: addLocaleToRoute

 /**
  * Adds the locale to the route if prepend_locale is enabled.
  *
  * @param Route $route The route
  */
 private function addLocaleToRoute(Route $route)
 {
     if ($this->prependLocale) {
         $route->setPath('/{_locale}' . $route->getPath());
         $route->addRequirements(['_locale' => '[a-z]{2}(\\-[A-Z]{2})?']);
     } else {
         $route->addDefaults(['_locale' => null]);
     }
 }
開發者ID:jamesdevine,項目名稱:core-bundle,代碼行數:14,代碼來源:FrontendLoader.php

示例7: addRequirements

 /**
  * Adds requirements.
  *
  * This method implements a fluent interface.
  *
  * @param array $requirements The requirements
  *
  * @return Route The current Route instance
  */
 public function addRequirements(array $requirements)
 {
     parent::addRequirements($requirements);
     $this->_addHeaderRequirements();
     return $this;
 }
開發者ID:gobjila,項目名稱:BackBee,代碼行數:15,代碼來源:Route.php


注:本文中的Symfony\Component\Routing\Route::addRequirements方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。