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


PHP RouteCollection::add方法代码示例

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


在下文中一共展示了RouteCollection::add方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testGeneratorDefaultsToApplicationRoutes

 public function testGeneratorDefaultsToApplicationRoutes()
 {
     $this->routes->push($app = new IlluminateRouteCollection());
     $app->add(new IlluminateRoute(['GET'], '/app', ['as' => 'foo', 'controller' => 'FooController@foo']));
     $this->routes->push($api = new ApiRouteCollection('v1'));
     $api->add(new ApiRoute(['GET'], '/api', ['as' => 'foo', 'controller' => 'FooController@foo']));
     $this->assertEquals('http://www.foo.com/app', $this->url->route('foo'));
     $this->assertEquals('http://www.foo.com/app', $this->url->action('FooController@foo'));
 }
开发者ID:jacobDaeHyung,项目名称:api,代码行数:9,代码来源:UrlGeneratorTest.php

示例2: mergeExistingRoutes

 /**
  * Merge the existing routes with the new routes.
  *
  * @param \Illuminate\Routing\RouteCollection $routes
  *
  * @return \Illuminate\Routing\RouteCollection
  */
 protected function mergeExistingRoutes(RouteCollection $routes)
 {
     if (!isset($this->oldRoutes)) {
         $this->oldRoutes = $this->router->getRoutes();
     }
     foreach ($this->oldRoutes as $route) {
         $routes->add($route);
     }
     return $routes;
 }
开发者ID:riclt,项目名称:api,代码行数:17,代码来源:Laravel.php

示例3: getRoutesByPrefix

 /**
  * @param string $prefix
  *
  * @return RouteCollection
  */
 public static function getRoutesByPrefix($prefix)
 {
     $prefix = ltrim(trim($prefix), '/');
     $routes = self::getRoutes();
     $prefixLength = strlen($prefix);
     $filteredRoutes = new RouteCollection();
     foreach ($routes as $route) {
         $uri = ltrim(trim($route->getUri()), '/');
         if (substr($uri, 0, $prefixLength) == $prefix) {
             $filteredRoutes->add($route);
         }
     }
     return $filteredRoutes;
 }
开发者ID:mohaiminul-sust,项目名称:laravel-apidocs,代码行数:19,代码来源:RouteResolver.php

示例4: addRoute

 /**
  * Add a route to the underlying route collection.
  *
  * @param  array|string  $methods
  * @param  string  $uri
  * @param  \Closure|array|string|null  $action
  * @return \Illuminate\Routing\Route
  */
 protected function addRoute($methods, $uri, $action)
 {
     return $this->routes->add($this->createRoute($methods, $uri, $action));
 }
开发者ID:samlev,项目名称:framework,代码行数:12,代码来源:Router.php

示例5: fire

 /**
  * Execute the console command.
  *
  * @return boolean
  */
 public function fire()
 {
     $this->call('route:clear');
     $routes = $this->getFreshApplicationRoutes();
     if (count($routes) == 0) {
         $this->error("Your application doesn't have any routes.");
         return false;
     }
     $languages = $this->laravel['config']['app.supported_locales'];
     $baseLanguage = $this->laravel['config']['app.locale'];
     foreach ($languages as $language) {
         $fileList[$language] = $this->files->allFiles(sprintf('%s/resources/lang/%s/routes', $this->laravel->basePath(), $language));
     }
     $localizedURIs = [];
     if (!empty($fileList) && is_array($fileList)) {
         /**
          * @var \Symfony\Component\Finder\SplFileInfo $file
          */
         foreach ($fileList as $language => $files) {
             foreach ($files as $file) {
                 $category = $file->getBasename('.php');
                 $localizedURIs[$language][$category] = (include $file->getRealPath());
             }
         }
     }
     $localizedRouteCollection = new RouteCollection();
     foreach ($languages as $language) {
         /**
          * @var \Illuminate\Routing\Route $route
          */
         foreach ($routes as $route) {
             //Keeping only our route information
             $route->prepareForSerialization();
             $action = $route->getAction();
             if (isset($action['category']) && isset($action['as'])) {
                 if (isset($localizedURIs[$language][$action['category']][$action['as']])) {
                     $tmp = clone $route;
                     $tmp->setUri($localizedURIs[$language][$action['category']][$action['as']]);
                     $action['as'] = $language . '.' . $action['as'];
                     $tmp->setAction($action);
                 }
             }
             $localizedRouteCollection->add($tmp);
         }
     }
     $this->files->put($this->laravel->getCachedRoutesPath(), $this->buildRouteCacheFile($localizedRouteCollection));
     $this->info('Localized routes cached successfully!');
     return true;
 }
开发者ID:linguisticteam,项目名称:laravel-boilerplate,代码行数:54,代码来源:LocalizedRouteCacheCommand.php


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