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


PHP Routing\RouteCollection类代码示例

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


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

示例5: resolveControllerByName

 /**
  * @param RouteCollection $routes
  *
  * @return Controller
  *
  * @throws ShapeShifterException
  */
 protected function resolveControllerByName(RouteCollection $routes)
 {
     $contr = $routes->getByName($this->destination);
     if (!$contr) {
         throw new ShapeShifterException("Route [{$this->destination}] does not exist");
     }
     list($class) = explode('@', $contr->getActionName());
     return app($class);
 }
开发者ID:wearejust,项目名称:shapeshifter,代码行数:16,代码来源:OneToManyRelation.php

示例6: getRoutes

 protected function getRoutes()
 {
     if (isset($this->routeCol)) {
         return;
     }
     $this->routeCol = $this->app['router']->getRoutes();
     $routes = $this->routeCol->getRoutes();
     array_walk($routes, function ($route) {
         foreach ($route->getMethods() as $method) {
             $this->routes[$method . '.' . $route->getUri()] = true;
         }
     });
 }
开发者ID:newmarkets,项目名称:content,代码行数:13,代码来源:TestCase.php

示例7: findRoute

 /**
  * Find the route matching a given request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Routing\Route
  */
 protected function findRoute($request)
 {
     $this->current = $route = $this->routes->match($request);
     //return $this->substituteBindings($route);
     // 目前不支持bind
     return $route;
 }
开发者ID:453111208,项目名称:bbc,代码行数:13,代码来源:router.php

示例8: check

 /**
  * Determine if a route in the array matches the request.
  *
  * @param array                    $routes
  * @param \Illuminate\http\Request $request
  * @param bool                     $includingMethod
  *
  * @return \Illuminate\Routing\Route|null
  */
 protected function check(array $routes, $request, $includingMethod = true)
 {
     $foundRoute = parent::check($routes, $request, $includingMethod);
     // If no route found, check if the 404 route is set, if so, return that route as our found route.
     if (!$foundRoute && isset($routes['404'])) {
         $foundRoute = $routes['404'];
     }
     return $foundRoute;
 }
开发者ID:themosis,项目名称:framework,代码行数:18,代码来源:RouteCollection.php

示例9: action

 /**
  * Get the URL to a controller action.
  *
  * @param  string  $action
  * @param  mixed   $parameters
  * @param  bool    $absolute
  * @return string
  */
 public function action($action, $parameters = array(), $absolute = true)
 {
     if ($this->rootNamespace && !(strpos($action, '\\') === 0)) {
         $action = $this->rootNamespace . '\\' . $action;
     } else {
         $action = trim($action, '\\');
     }
     return $this->route($action, $parameters, $absolute, $this->routes->getByAction($action));
 }
开发者ID:AlexCutts,项目名称:framework,代码行数:17,代码来源:UrlGenerator.php

示例10: action

 /**
  * Get the URL to a controller action.
  *
  * @param  string  $action
  * @param  mixed   $parameters
  * @param  bool    $absolute
  * @return string
  *
  * @throws \InvalidArgumentException
  */
 public function action($action, $parameters = [], $absolute = true)
 {
     if ($this->rootNamespace && !(strpos($action, '\\') === 0)) {
         $action = $this->rootNamespace . '\\' . $action;
     } else {
         $action = trim($action, '\\');
     }
     if (!is_null($route = $this->routes->getByAction($action))) {
         return $this->toRoute($route, $parameters, $absolute);
     }
     throw new InvalidArgumentException("Action {$action} not defined.");
 }
开发者ID:hilmysyarif,项目名称:sisfito,代码行数:22,代码来源:UrlGenerator.php

示例11: match

 /**
  * Find the first route matching a given request.
  *
  * @param  \Illuminate\Http\Request $request
  *
  * @return \Illuminate\Routing\Route
  * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
  */
 public function match(Request $request)
 {
     $hasWpParams = $request->path() == '/' && ($request->has('p') || $request->has('post_id'));
     if ($hasWpParams && ($route = $this->findMatchingWordPressPost($request))) {
         return $route;
     }
     try {
         return parent::match($request);
     } catch (NotFoundHttpException $e) {
         if ($route = $this->findMatchingWordPressPost($request)) {
             return $route;
         }
         throw $e;
     }
 }
开发者ID:ericbarnes,项目名称:framework,代码行数:23,代码来源:RouteCollection.php

示例12: makesByType

 /**
  * Make permission instances by type
  *
  * @param string                $type    type string
  * @param MemberEntityInterface $user    user instance
  * @param string                $siteKey site key
  * @return Permission[]
  * @throws NotMatchedInstanceException
  */
 public function makesByType($type, MemberEntityInterface $user = null, $siteKey = 'default')
 {
     $user = $user ?: $this->auth->user();
     $permissions = [];
     $registereds = $this->repo->fetchByType($siteKey, $type);
     foreach ($registereds as $registered) {
         $ancestors = array_filter($registereds, function ($item) use($registered) {
             $itemNames = explode('.', $item->name);
             $registeredNames = explode('.', $registered->name);
             if (count($itemNames) >= count($registeredNames)) {
                 return false;
             }
             for ($i = 0; $i < count($itemNames); $i++) {
                 if ($itemNames[$i] !== $registeredNames[$i]) {
                     return false;
                 }
             }
             return true;
         });
         if (count($ancestors) > 0) {
             uasort($ancestors, [$this, 'cmp']);
         }
         foreach ($ancestors as $ancestor) {
             $registered->addParent($ancestor);
         }
         if (isset($this->extends[$type]) === true) {
             $permission = $this->extends[$type]($registered->name, $user, $registered);
             if ($permission instanceof Permission === false) {
                 throw new NotMatchedInstanceException(['type' => $type]);
             }
             $permissions[$registered->name] = $permission;
         } else {
             switch ($type) {
                 case 'route':
                     $route = $this->routes->getByName($registered->name);
                     $permissions[$registered->name] = new RoutePermission($route, $user, $registered);
                     break;
                 case 'instance':
                     $permissions[$registered->name] = new InstancePermission($registered->name, $user, $registered);
                     break;
             }
         }
     }
     return $permissions;
 }
开发者ID:qkrcjfgus33,项目名称:xpressengine,代码行数:54,代码来源:Factory.php

示例13: has

 /**
  * Check if a route with the given name exists.
  *
  * @param  string  $name
  * @return bool
  */
 public function has($name)
 {
     return $this->routes->hasNamedRoute($name);
 }
开发者ID:samlev,项目名称:framework,代码行数:10,代码来源:Router.php

示例14: action

 /**
  * Get the URL to a controller action.
  *
  * @param  string  $action
  * @param  mixed   $parameters
  * @param  bool    $absolute
  * @return string
  */
 public function action($action, $parameters = array(), $absolute = true)
 {
     return $this->route($action, $parameters, $absolute, $this->routes->getByAction($action));
 }
开发者ID:solangegamboa,项目名称:teste-php,代码行数:12,代码来源:UrlGenerator.php

示例15: getRouteForRequest

 /**
  * @param Request $request
  *
  * @return \Illuminate\Routing\Route|null
  */
 public function getRouteForRequest(Request $request)
 {
     $routes = $this->collection->get($request->getMethod());
     return $this->collection->check($routes, $request);
 }
开发者ID:digbang,项目名称:security,代码行数:10,代码来源:RouteCollectionMatcher.php


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