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


PHP Routes::map方法代码示例

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


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

示例1: create_route

 public function create_route()
 {
     $route_string = $this->containing_post_type . "/:name/" . $this->contained_post_type;
     \Routes::map($route_string, function ($params) {
         $posts = get_posts(array('name' => $params['name'], 'post_type' => $this->containing_post_type));
         if ($posts) {
             $wp_post = $posts[0];
             $query = array('post_type' => $this->contained_post_type, 'connected_type' => $this->p2p_connection_type, 'connected_items' => $wp_post->ID);
         }
         $params += array('archive_title' => $this->get_archive_title_string($wp_post, $this->contained_post_type), 'containing_post_type' => $this->containing_post_type, 'contained_post_type' => $this->contained_post_type, 'p2p_connection_type' => $this->p2p_connection_type);
         \Routes::load($this->template, $params, $query, 200);
     });
     $paginated_route_string = $this->containing_post_type . "/:name/" . $this->contained_post_type . "/page/:pg";
     \Routes::map($paginated_route_string, function ($params) {
         $posts = get_posts(array('name' => $params['name'], 'post_type' => $this->containing_post_type));
         if ($posts) {
             $wp_post = $posts[0];
             $query = array('post_type' => $this->contained_post_type, 'connected_type' => $this->p2p_connection_type, 'connected_items' => $wp_post->ID, 'paged' => $params['pg']);
             $params += array('archive_title' => $this->get_archive_title_string($wp_post, $this->contained_post_type), 'containing_post_type' => $this->containing_post_type, 'contained_post_type' => $this->contained_post_type, 'p2p_connection_type' => $this->p2p_connection_type);
         }
         \Routes::load($this->template, $params, $query, 200);
     });
 }
开发者ID:bermanco,项目名称:extended-timber-classes,代码行数:23,代码来源:P2PRouteCreator.php

示例2: add_route

 /**
  * Add route.
  *
  * @param string  $route
  * @param callable $callback
  * @param array   $args
  * @deprecated since 0.20.0
  */
 public static function add_route($route, $callback, $args = array())
 {
     Routes::map($route, $callback, $args);
 }
开发者ID:Butterwell,项目名称:timber,代码行数:12,代码来源:timber.php

示例3: add_route

 /**
  * Add route.
  *
  * @param string  $route
  * @param callable $callback
  * @param array   $args
  * @deprecated since 0.20.0 and will be removed in 1.1
  */
 public static function add_route($route, $callback, $args = array())
 {
     Helper::warn('Timber::add_route (and accompanying methods for load_view, etc. Have been deprecated and will soon be removed. Please update your theme with Route::map. You can read more in the 1.0 Upgrade Guide: https://github.com/timber/timber/wiki/1.0-Upgrade-Guide');
     \Routes::map($route, $callback, $args);
 }
开发者ID:darbymanning,项目名称:Family-Church,代码行数:13,代码来源:Timber.php

示例4: testRouteWithClassCallback

 function testRouteWithClassCallback()
 {
     Routes::map('classroute', array('TestRoutes', 'testCallback'));
     $this->go_to(home_url('classroute'));
     $this->matchRoutes();
     global $matches;
     $this->assertEquals(1, count($matches));
 }
开发者ID:mazykin46,项目名称:portfolio,代码行数:8,代码来源:test-routes.php

示例5:

<?php

Routes::map(':controller/:action/:id');
开发者ID:pilaf,项目名称:yarr,代码行数:3,代码来源:routes.php

示例6: testVerySimpleRoutePreceedingSlash

 function testVerySimpleRoutePreceedingSlash()
 {
     $_SERVER['REQUEST_METHOD'] = 'GET';
     global $matches;
     $matches = array();
     $phpunit = $this;
     Routes::map('/gobbles', function () use($phpunit) {
         global $matches;
         $matches = array();
         $matches[] = true;
     });
     $this->go_to(home_url('gobbles'));
     $this->matchRoutes();
     $this->assertEquals(1, count($matches));
 }
开发者ID:mrgrain,项目名称:timber,代码行数:15,代码来源:test-timber-router.php


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