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


PHP Route::name方法代码示例

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


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

示例1: before

 public function before()
 {
     $directory = $this->request->directory();
     $controller = $this->request->controller();
     $action = $this->request->action();
     $format = $this->_detect_response_format();
     $mime = File::mime_by_ext($format) ?: 'text/html';
     $this->response->view(['basedir' => $controller, 'directory' => $directory, 'action' => $action, 'format' => $format]);
     $this->response->view->set(['basedir' => $controller, 'directory' => $directory, 'controller' => $controller, 'action' => $action, 'format' => $format, 'request' => $this->request, 'method' => $this->request->method(), 'secure' => $this->request->secure(), 'route' => $this->request->route(), 'route_name' => Route::name($this->request->route()), 'params' => $this->request->param(), 'query' => $this->request->query()]);
     $this->format = $format;
     if ($this->_layout === NULL) {
         $layout = strtolower($controller);
         if ($this->response->view->viewfile_exists($layout, 'layouts')) {
             $this->_layout = $layout;
         } else {
             if ($this->response->view->viewfile_exists($this->_default_layout, 'layouts')) {
                 $this->_layout = $this->_default_layout;
             }
         }
     }
     $this->response->headers('Content-Type', $mime . '; charset=' . Kohana::$charset);
     if ($this->_layout) {
         View::layout($this->_layout);
     }
     $this->_before_action && $this->_call_method_for_action($this->_before_action);
 }
开发者ID:alshabalin,项目名称:kohana-advanced-view,代码行数:26,代码来源:Controller.php

示例2: create_tests

 /**
  * Get an array of Route_Tester objects from the config settings
  *
  * @param  $tests  A URL to test, or an array of URLs to test.
  * @returns array  An array of Route_Tester objects
  */
 public static function create_tests($tests)
 {
     if (is_string($tests)) {
         $tests = array($tests);
     }
     $array = array();
     // Get the url and optional expected_params from the config
     foreach ($tests as $key => $value) {
         $current = new Route_Tester();
         if (is_array($value)) {
             $url = $key;
             $current->expected_params = $value;
         } else {
             $url = $value;
         }
         $current->url = trim($url, '/');
         // Test each route, and save the route and params if it matches
         foreach (Route::all() as $route) {
             if ($current->params = $route->matches(Request::factory($current->url))) {
                 $current->route = Route::name($route);
                 $current->params = array_merge(array('route' => $current->route), $current->params);
                 break;
             }
         }
         $array[] = $current;
     }
     return $array;
 }
开发者ID:seyfer,项目名称:kohana-devtools,代码行数:34,代码来源:Tester.php

示例3: test_name_returns_routes_name_or_false_if_dnx

 /**
  * Route::name() should fetch the name of a passed route
  * If route is not found then it should return FALSE
  *
  * @TODO: This test needs to segregate the Route::$_routes singleton
  * @test
  * @covers Route::name
  */
 public function test_name_returns_routes_name_or_false_if_dnx()
 {
     $route = Route::set('flamingo_people', 'flamingo/dance');
     $this->assertSame('flamingo_people', Route::name($route));
     $route = new Route('dance/dance');
     $this->assertFalse(Route::name($route));
 }
开发者ID:robert-kampas,项目名称:games-collection-manager,代码行数:15,代码来源:RouteTest.php

示例4: error

 public function error($message)
 {
     $this->response->status(404);
     $this->template->title = "Userguide - Error";
     $this->template->content = View::factory('userguide/error', array('message' => $message));
     // Don't show disqus on error pages
     $this->template->show_comments = FALSE;
     // If we are in a module and that module has a menu, show that
     if ($module = $this->request->param('module') and $menu = $this->file($module . '/menu') and Kohana::$config->load('userguide.modules.' . $module . '.enabled')) {
         // Namespace the markdown parser
         Kodoc_Markdown::$base_url = URL::site($this->guide->uri()) . '/' . $module . '/';
         Kodoc_Markdown::$image_url = URL::site($this->media->uri()) . '/' . $module . '/';
         $this->template->menu = Kodoc_Markdown::markdown($this->_get_all_menu_markdown());
         $this->template->breadcrumb = array($this->guide->uri() => 'User Guide', $this->guide->uri(array('module' => $module)) => Kohana::$config->load('userguide.modules.' . $module . '.name'), 'Error');
     } else {
         if (Route::name($this->request->route()) == 'docs/api') {
             $this->template->menu = Kodoc::menu();
             // Bind the breadcrumb
             $this->template->breadcrumb = array($this->guide->uri(array('page' => NULL)) => 'User Guide', $this->request->route()->uri() => 'API Browser', 'Error');
         } else {
             $this->template->menu = View::factory('userguide/menu', array('modules' => $this->_modules()));
             $this->template->breadcrumb = array($this->request->route()->uri() => 'User Guide', 'Error');
         }
     }
 }
开发者ID:bedmansz,项目名称:ecomm,代码行数:25,代码来源:userguide.php

示例5: confirm_restore

 /**
  * Confirm restore password
  * @param $user_id
  * @param $user_email
  * @param $expires
  * @return bool
  */
 public static function confirm_restore($user_id, $user_email, $expires = Date::DAY)
 {
     $config = Kohana::$config->load('app');
     $url_confirmed = HTML::anchor(Kohana::$server_name . Route::url(Route::name(Request::$current->route()), ['action' => 'confirmed_restore', 'token' => Model_User_Confirm::token($user_id, Model_User_Confirm::TYPE_RESTORE, $expires)]), 'confirm the password change');
     $msg = "<p>Please <strong>{$url_confirmed}</strong> to change your password.</p>";
     // Send new password
     return Mail::sendmail($user_email, $config['site_email'], $config['site_subject'] . ' restore password ' . $config['sitename'], $msg);
 }
开发者ID:eok8177,项目名称:shopCMS,代码行数:15,代码来源:Mail.php

示例6: fromArray

 /**
  * 
  * @param array $routes
  * @return Routes
  */
 public function fromArray($routes)
 {
     $this->clearRoutes();
     foreach ($routes as $name => $routeData) {
         $routeData['name'] = $name;
         $route = new Route();
         $route->fromArray($routeData);
         if ($route->isValid()) {
             $this->routes[$route->name()] = $route;
         }
     }
 }
开发者ID:mzieba,项目名称:zpp-slim-basic,代码行数:17,代码来源:Routes.php

示例7: testRouteSetsNameAndIsCached

 /**
  * Route should set name and be cached by Router
  */
 public function testRouteSetsNameAndIsCached()
 {
     $router = new RouterMock();
     $route = new Route('/foo/bar', function () {
     });
     $route->setRouter($router);
     $route->name('foo');
     $cacheKeys = array_keys($router->cache);
     $cacheValues = array_values($router->cache);
     $this->assertEquals($cacheKeys[0], 'foo');
     $this->assertSame($cacheValues[0], $route);
 }
开发者ID:Jud,项目名称:Slim,代码行数:15,代码来源:RouteTest.php

示例8: _changed_uri

 protected function _changed_uri($params)
 {
     if (is_string($params)) {
         // assume its an action name
         $params = array('action' => $params);
     }
     $current_params = $this->request->param();
     $current_params['controller'] = strtolower($this->request->controller());
     $current_params['directory'] = strtolower($this->request->directory());
     $current_params['action'] = strtolower($this->request->action());
     $params = $params + $current_params;
     return Route::url(Route::name(Request::current()->route()), $params, TRUE);
 }
开发者ID:ortodesign,项目名称:cms,代码行数:13,代码来源:controller.php

示例9: _get_page_links

 protected function _get_page_links($count, $offset, $limit)
 {
     $links = array();
     $route = Route::name($this->request->route());
     $query = $this->request->query();
     $internal = array('kohana_uri' => null, 'oauth_consumer_key' => null, 'oauth_nonce' => null, 'oauth_signature_method' => null, 'oauth_timestamp' => null, 'oauth_token' => null, 'oauth_version' => null, 'oauth_signature' => null);
     $query = array_diff_key($query, $internal);
     $query['limit'] = $limit;
     if ($count > ($query['offset'] = $offset + $limit)) {
         $links[] = Controller_Resources::to_href('next', $route, $this->request->param(), $query);
     }
     if (0 <= ($query['offset'] = $offset - $limit)) {
         $links[] = Controller_Resources::to_href('previous', $route, $this->request->param(), $query);
     }
     return $links;
 }
开发者ID:gianebao,项目名称:kohana-rest,代码行数:16,代码来源:Responses.php

示例10: init

 protected function init()
 {
     $request = $this->request->current();
     $this->config = Kohana::$config->load($this->config)->as_array();
     $this->acl_init();
     $this->site_init();
     $helper_acl = new Helper_ACL($this->acl);
     $a2_config = Kohana::$config->load('admin/a2/base')->as_array();
     $helper_acl->inject($a2_config);
     if (Route::name($request->route()) == 'modules') {
         $this->module_page_id = (int) $request->query('page');
         $this->module_config = empty($this->module_config) ? Helper_Module::code_by_controller($request->controller()) : $this->module_config;
         $_pages = $this->get_module_pages($this->module_config);
         if ($_pages->count() > 0) {
             if ($this->module_page_id == 0) {
                 $this->module_page_id = $_pages->rewind()->current()->id;
             }
             foreach ($_pages as $_item) {
                 $_link = URL::base() . Page_Route::dynamic_base_uri($_item->id);
                 $this->module_pages[$_item->id] = $_item->title . " [ {$_link} ]";
             }
         }
         $this->module_config = Helper_Module::load_config($this->module_config);
         if (!Kohana::$is_cli) {
             $config = Arr::get($this->module_config, 'a2');
             $helper_acl->inject($config);
         }
         if (!$this->acl->is_allowed($this->user, $request->controller() . '_controller', 'access')) {
             throw new HTTP_Exception_404();
         }
     }
     $injectors = array();
     foreach ($this->injectors as $_key => $_array) {
         $params = Arr::get($_array, 1);
         if (class_exists($_array[0])) {
             $object = new $_array[0]($request, $this->user, $this->acl, $params);
             $injectors[$_key] = $object;
         }
     }
     $this->injectors = $injectors;
     unset($injectors);
     $this->is_cancel = $request->post('cancel') == 'cancel';
     $this->back_url = $request->query('back_url');
     $this->post_check_empty_files();
     $this->post_check_deleted_fields();
 }
开发者ID:greor,项目名称:satin-spb,代码行数:46,代码来源:base.php

示例11: collectData

 /**
  * Collect all data
  * @static
  * @return void
  */
 private static function collectData()
 {
     if (!Request::$current || Route::name(Request::$current->route()) == self::$_data_collect_current_route) {
         return;
     }
     self::$DATA_APP_TIME = self::getAppTime();
     self::$DATA_APP_MEMORY = self::getAppMemory();
     self::$DATA_SQL = self::getSql();
     self::$DATA_CACHE = self::getCache();
     self::$DATA_POST = self::getPost();
     self::$DATA_GET = self::getGet();
     self::$DATA_FILES = self::getFiles();
     self::$DATA_COOKIE = self::getCookie();
     self::$DATA_SESSION = self::getSession();
     self::$DATA_SERVER = self::getServer();
     self::$DATA_ROUTES = self::getRoutes();
     self::$DATA_INC_FILES = self::getIncFiles();
     self::$DATA_CUSTOM = self::getCustom();
     self::$_data_collect_current_route = Route::name(Request::$current->route());
 }
开发者ID:tscms,项目名称:profilertoolbar,代码行数:25,代码来源:ProfilerToolbar.php

示例12: init

 /**
  * Initial data loading
  */
 public static function init()
 {
     if (in_array(Route::name(Request::instance()->route), self::$ignored_routes)) {
         return FALSE;
     }
     // don't call init() twice!
     if (self::$_loaded) {
         return FALSE;
     }
     self::$_session = Session::instance();
     // load session data
     self::$_olddata = self::$_session->get(self::$_session_var, FALSE);
     // clear session data
     self::$_session->delete(self::$_session_var);
     if (self::$_olddata == FALSE) {
         // create empty array - there is no data
         self::$_olddata = array();
     }
     self::$_data = self::$_olddata;
     self::$_loaded = TRUE;
 }
开发者ID:biakaveron,项目名称:message,代码行数:24,代码来源:message.php

示例13: __construct

 /**
  * Setup adapter
  * 
  * @param Jelly_Builder $source
  * @param array $config pagination config
  */
 public function __construct(Jelly_Builder $source, array $config = null)
 {
     $this->_target = new Pagination();
     $this->_source = $source;
     //merge config
     $this->_config += $this->_target->config_group();
     //merge config
     if ($config) {
         $this->_config += $config;
     }
     $order_how = isset($this->_config['current_order']) ? Request::current()->query($this->_config['current_order']['key']) : 'DESC';
     $this->_direct = $order_how == 'DESC' ? 'ASC' : 'DESC';
     $this->_limit = isset($this->_config['current_limit']) ? Request::current()->query($this->_config['current_limit']['key']) ? Request::current()->query($this->_config['current_limit']['key']) : 10 : 10;
     $this->_sort_column = Request::current()->query($this->_config['current_sort']['key']);
     $this->_target->setup(array('total_items' => $source->select()->count(), 'items_per_page' => $this->_limit));
     if (!is_null($this->_sort_column)) {
         $this->_source->order_by($this->_sort_column, $order_how);
     }
     // Get the current route name
     $current_route = Route::name(Request::initial()->route());
     //Current route
     $this->_route = Route::get($current_route);
 }
开发者ID:piotrtheis,项目名称:jelly,代码行数:29,代码来源:adapter.php

示例14: render

 /**
  * @return string HTML anchor
  */
 public function render($include_classes = false)
 {
     $title = $this->_render_icon() . $this->_config['title'];
     if ($this->last == true) {
         return $title;
     } else {
         $is_current = Route::name(Request::$initial->route()) == $this->_config['route'];
         // Apply URL::site
         if (isset($this->_config['route'])) {
             $route_params = array();
             if (isset($this->_config['route_param']) && count($this->_config['route_param'] > 0)) {
                 foreach ($this->_config['route_param'] as $param) {
                     if ($this->_element->route_params[$this->_config['route']] == null) {
                         if ($is_current) {
                             $route_params[$param] = Request::$initial->param($param);
                         } else {
                             throw new Kohana_Exception('Route parameters aren\'t set for ":route"', array(':route' => $this->_config['route']));
                         }
                     } else {
                         $route_params[$param] = $this->_element->route_params[$this->_config['route']][$param];
                     }
                 }
             }
             $this->_config['url'] = Route::url($this->_config['route'], $route_params, true);
         } else {
             if (!'http://' == substr($this->_config['url'], 0, 7) and !'https://' == substr($this->_config['url'], 0, 8)) {
                 $this->_config['url'] = URL::site($this->_cornfig['url']);
             }
         }
         $attr = ['title' => $this->_config['tooltip']];
         if ($include_classes == true) {
             $attr['class'] = implode(' ', $this->_config['classes']);
         }
         return HTML::anchor($this->_config['url'], $title, $attr, NULL, FALSE);
     }
 }
开发者ID:happydemon,项目名称:elements,代码行数:39,代码来源:Item.php

示例15: foreach

	#results.fail { background: #911; }
	
</style>


<h1>Route Dump</h1>

<?php 
if (count(Route::all()) > 0) {
    ?>
	
	<?php 
    foreach (Route::all() as $route) {
        ?>
	<h3><?php 
        echo Route::name($route);
        ?>
</h3>
		<?php 
        $array = (array) $route;
        foreach ($array as $key => $value) {
            $new_key = substr($key, strrpos($key, "") + 1);
            $array[$new_key] = $value;
            unset($array[$key]);
        }
        ?>
		<table>
			<tr>
				<th>Route uri</th>
				<td><code><?php 
        echo html::chars($array['_uri']);
开发者ID:ametsuramet,项目名称:belajar_kohana,代码行数:31,代码来源:route-dump.php


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