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


PHP Route::getPrefix方法代码示例

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


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

示例1: matches

 /**
  * Validate a given rule against a route and request.
  *
  * @param  \Illuminate\Routing\Route $route
  * @param  \Illuminate\Http\Request $request
  *
  * @return bool
  */
 public function matches(Route $route, Request $request)
 {
     $this->route = $route;
     $this->request = $request;
     $uri = $route->uri();
     $prefix = $route->getPrefix();
     // Transform the $uri to the form of `prefix.URI-fragment`   e.g. `page.about`
     if (!empty($prefix)) {
         $uri = str_replace('/', '.', $uri);
     }
     // if the current page is a generic page
     // then just use the uri to test
     if ($this->is_generic($uri)) {
         return $this->is_it_matches($uri);
     }
     // if the current page is a specified page
     // extract the post type and post slug
     $post_info = explode('.', $uri);
     $post_type = $post_info[0];
     $post_slug = $post_info[1];
     $post_info_greater_than_2 = count($post_info) > 2;
     $post_hierarchy = array_slice($post_info, 1);
     if ($post_type === 'category' and \is_category()) {
         $isSubCategory = $post_info_greater_than_2;
         if ($isSubCategory) {
             $cat = get_category(get_query_var('cat'));
             $hierarchy = $this->get_category_parents($cat);
             array_push($hierarchy, urldecode($cat->slug));
             return $hierarchy == $post_hierarchy;
         }
     }
     if ($post_type === 'taxonomy' and \is_tax()) {
         $isSubTerm = $post_info_greater_than_2;
         if ($isSubTerm) {
             $taxonomy = get_query_var('taxonomy');
             $term = get_term_by('slug', get_query_var('term'), $taxonomy);
             $hierarchy = $this->get_taxonomy_parents($term, $post_slug);
             array_unshift($hierarchy, $taxonomy);
             array_push($hierarchy, urldecode($term->slug));
             return $hierarchy == $post_hierarchy;
         }
         return \is_tax($post_slug);
     }
     if ($post_type === 'page' and \is_page()) {
         // if sub-page is supplied, detect if the current page matches
         $isSubPage = count($post_info) > 2;
         if ($isSubPage) {
             $currentPost = \get_post(\get_the_ID());
             $hierarchy = $this->get_page_parents($currentPost);
             array_push($hierarchy, $currentPost->post_name);
             return $hierarchy == $post_hierarchy;
         }
     }
     return $this->is_it_matches($post_type, $post_slug);
 }
开发者ID:laraish,项目名称:framework,代码行数:63,代码来源:UriValidator.php

示例2: to

 /**
  * @param $method
  * @param array $params
  * @return string
  */
 protected function to($method, array $params = [])
 {
     $prefix = $this->route->getPrefix();
     return route($prefix . '.' . $this->resource->name() . '.' . $method, $params);
 }
开发者ID:cocona,项目名称:core,代码行数:10,代码来源:ResourceController.php

示例3: getRouteInformation

 /**
  * Get the route information for a given route.
  *
  * @param  string  $name
  * @param  \Illuminate\Routing\Route  $route
  * @return array
  */
 protected function getRouteInformation(Route $route)
 {
     $uri = implode('|', $route->methods()) . ' ' . $route->uri();
     return $this->filterRoute(array('host' => $route->domain(), 'uri' => $uri, 'name' => $route->getName(), 'action' => $route->getActionName(), 'prefix' => $route->getPrefix(), 'method' => $route->methods()[0]));
 }
开发者ID:f2m2,项目名称:apidocs,代码行数:12,代码来源:ApiDocsGenerator.php


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