当前位置: 首页>>代码示例>>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;未经允许,请勿转载。