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


PHP Route::addOptions方法代码示例

本文整理汇总了PHP中Symfony\Component\Routing\Route::addOptions方法的典型用法代码示例。如果您正苦于以下问题:PHP Route::addOptions方法的具体用法?PHP Route::addOptions怎么用?PHP Route::addOptions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Component\Routing\Route的用法示例。


在下文中一共展示了Route::addOptions方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: load

 public function load($resource, $type = null)
 {
     $collection = new RouteCollection();
     //load static routes
     $importedRoutes = $this->import('@AppBundle/Resources/config/static-routing.yml', 'yaml');
     $collection->addCollection($importedRoutes);
     //load dynamic routes from database
     $pages = $this->doctrine->getRepository('DataBundle:Page')->findBy(['active' => true], ['ordering' => 'asc']);
     $importedRoutes = new RouteCollection();
     //add default page if no pages are defined
     if (count($pages) == 0) {
         $route = new Route('/', ['_controller' => 'AppBundle:Page:defaultIndex']);
         $importedRoutes->add('index', $route);
     }
     foreach ($pages as $page) {
         $route = new Route('/' . $page->getSlug(), ['_controller' => 'AppBundle:Page:page']);
         //todo: make slug conversion safe
         if ($page->getIsIndex()) {
             $name = 'index';
         } else {
             $name = str_replace('/', '', strtolower(trim($page->getTitle())));
         }
         $importedRoutes->add($name, $route);
         //generate blog post url for tag
         if ($page->getIsBlogTag() && !is_null($page->getTag())) {
             $route = new Route('/' . trim($page->getSlug()) . '/post/{slug}', ['_controller' => 'AppBundle:Page:post']);
             $route->addOptions(['post_from' => 'tag']);
             $name = str_replace('/', '', strtolower(trim($page->getTitle())) . '_post');
             $importedRoutes->add($name, $route);
         }
         //generate blog post url for blog
         if ($page->getIsBlog() && !is_null($page->getBlog())) {
             $route = new Route('/' . trim($page->getSlug()) . '/post/{slug}', ['_controller' => 'AppBundle:Page:post']);
             $route->addOptions(['post_from' => 'blog']);
             $name = str_replace('/', '', strtolower(trim($page->getTitle())) . '_post');
             $importedRoutes->add($name, $route);
         }
     }
     $collection->addCollection($importedRoutes);
     return $collection;
 }
开发者ID:itaw,项目名称:cms,代码行数:41,代码来源:DynamicRouter.php


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