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


PHP Route::set方法代码示例

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


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

示例1: set_route

 public static function set_route($config)
 {
     $myroutes = Kohana::$config->load($config);
     foreach ($myroutes as $name => $rout) {
         Route::set($name, $rout["URI"])->defaults($rout["defaults"]);
     }
 }
开发者ID:Osa32,项目名称:chat,代码行数:7,代码来源:MyRoutes.php

示例2: test_is_method_allowed

 /**
  * @dataProvider data_is_method_allowed
  */
 public function test_is_method_allowed($route_method, $requested_method, $expected_result)
 {
     $this->markTestSkipped();
     $route = Route::set('route_check', 'uri', NULL, array('method' => $route_method))->defaults(array('controller' => 'uri'));
     $request = new Request('uri');
     $request->method($requested_method);
     $this->assertEquals($expected_result, $route->is_method_allowed($route, array(), $request));
 }
开发者ID:openbuildings,项目名称:jam-resource,代码行数:11,代码来源:RouteTest.php

示例3: set_routes

 public static function set_routes($config)
 {
     $routes = Kohana::$config->load($config);
     foreach ($routes as $name => $rout) {
         if (isset($rout["regexp"])) {
             Route::set($name, $rout["URI"], $rout["regexp"])->defaults($rout["defaults"]);
         } else {
             Route::set($name, $rout["URI"])->defaults($rout["defaults"]);
         }
     }
 }
开发者ID:qlsove,项目名称:faq,代码行数:11,代码来源:Site.php

示例4: write

 /**
  * Route
  *
  * @return Route
  */
 public static function write()
 {
     // Get backend name
     $backend_name = Cms_Helper::settings('backend_name');
     // Backend Auth
     Route::set('backend_auth', $backend_name . '/<action>', array('action' => '(directuser|login|logout)'))->defaults(array('directory' => 'backend', 'controller' => 'auth'));
     // Backend Media
     Route::set('backend_media', $backend_name . '/media(/<stuff>)', array('stuff' => '.*'))->defaults(array('directory' => 'backend', 'controller' => 'media', 'action' => 'index'));
     // Backend items
     Route::set('backend_items', $backend_name . '/items/<division>(/<action>(/<key>))')->filter(function ($route, $params, $request) {
         foreach ($params as &$param) {
             $param = str_replace('-', '_', $param);
         }
         return $params;
     })->defaults(array('directory' => 'backend', 'controller' => 'items', 'action' => 'index'));
     // Backend
     Route::set('backend', $backend_name . '(/<controller>(/<action>(/<key>)))')->filter(function ($route, $params, $request) {
         foreach ($params as &$param) {
             $param = str_replace('-', '_', Text::ucfirst($param));
         }
         return $params;
     })->defaults(array('directory' => 'backend', 'controller' => 'home', 'action' => 'index'));
     // Media
     Route::set('media', 'media(/<stuff>)', array('stuff' => '.*'))->defaults(array('controller' => 'media', 'action' => 'index'));
     // Imagefly
     // imagefly/1/w253-h253-p/test4.jpg
     Route::set('imagefly', 'imagefly(/<stuff>)', array('stuff' => '.*'))->defaults(array('controller' => 'imagefly', 'action' => 'index'));
     // Item
     Route::set('item', '<stuff>', array('stuff' => '.*'))->filter(function ($route, $params, $request) {
         foreach ($params as &$param) {
             $param = str_replace('-', '_', Text::ucfirst($param));
         }
         $stuffs = explode('/', $params['stuff']);
         $end_staff = end($stuffs);
         $segment = substr($end_staff, 0, strlen($end_staff) - (strpos($end_staff, '.') - 1));
         if (!$segment) {
             $segment = Cms_Helper::settings('home_page');
         }
         $params['segment'] = $segment;
         $item = (bool) DB::select('id')->from('items')->where('segment', '=', $segment)->execute()->get('id');
         if (!$item) {
             return FALSE;
         }
         return $params;
     })->defaults(array('controller' => 'item', 'action' => 'index'));
 }
开发者ID:deraemons,项目名称:deraemon-cms,代码行数:51,代码来源:Route.php

示例5: set_routes

 public static function set_routes($config)
 {
     $routes = Kohana::$config->load($config);
     $data = explode('.', $config);
     if (count($data) == 1) {
         foreach ($routes as $name => $rout) {
             if (isset($rout["regexp"])) {
                 Route::set($name, $rout["URI"], $rout["regexp"])->defaults($rout["defaults"]);
             } else {
                 Route::set($name, $rout["URI"])->defaults($rout["defaults"]);
             }
         }
     }
     if (count($data) == 2) {
         if (isset($rout["regexp"])) {
             Route::set($data[1], $routes["URI"], $routes["regexp"])->defaults($routes["defaults"]);
         } else {
             Route::set($data[1], $routes["URI"])->defaults($routes["defaults"]);
         }
     }
 }
开发者ID:qlsove,项目名称:chat,代码行数:21,代码来源:Site.php

示例6: __construct

 /**
  * Creates a new instance of the class
  * @param  int  optional specific site load id
  */
 public function __construct($site_id = NULL)
 {
     $this->_id = $site_id === NULL ? $this->_lookup() : $site_id;
     $this->_site = ORM::factory('site', $this->_id);
     if (!$this->_site->loaded()) {
         throw new Kohana_Exception('The KMS Site ID :site: could not be found/loaded from the database', array(':site:' => $this->_id));
     }
     foreach ($this->_site->routes->find_all() as $route) {
         $regexps = array();
         $defaults = array();
         foreach ($route->defaults->find_all() as $default) {
             $defaults[$default->key] = $default->value;
         }
         foreach ($route->regexps->find_all() as $regexp) {
             $regexps[$regexp->key] = $regexp->regexp;
         }
         $new_route = Route::set('kms_' . $route->name, $route->route, $regexps);
         if (!empty($defaults)) {
             $new_route->defaults($defaults);
         }
     }
 }
开发者ID:ngonchan,项目名称:Kooshy,代码行数:26,代码来源:site.php

示例7: Log_File

    Kohana::$log->attach(new Log_File(APPPATH . 'logs'));
}
/**
 * Default path for uploads directory.
 * Path are referenced by a relative or absolute path.
 */
Upload::$default_directory = APPPATH . 'uploads';
/**
 * Set the routes
 *
 * Each route must have a minimum of a name,
 * a URI and a set of defaults for the URI.
 *
 * Example:
 * ~~~
 *	Route::set('frontend/page', 'page(/<action>)')
 *		->defaults(array(
 *			'controller' => 'page',
 *			'action' => 'view',
 *	));
 * ~~~
 *
 * @uses  Path::lookup
 * @uses  Route::cache
 * @uses  Route::set
 */
if (!Route::cache()) {
    Route::set('default', '(<controller>(/<action>(/<id>)))')->filter('Path::lookup')->defaults(array('controller' => 'welcome', 'action' => 'index'));
    // Cache the routes in production
    Route::cache(Kohana::$environment === Kohana::PRODUCTION);
}
开发者ID:MenZil-Team,项目名称:cms,代码行数:31,代码来源:bootstrap.php

示例8: set_route

	/**
	 * Set route functionality.
	 *
	 * @return  void
	 */
	public static function set_route()
	{
		Route::set('Publicize', array('Publicize', 'route_callback'));
	}
开发者ID:nexeck,项目名称:kohana-publicize,代码行数:9,代码来源:publicize.php

示例9: defined

<?php

defined('SYSPATH') or die('No direct script access.');
/**
 * @version SVN: $Id:$
 */
$adminPrefix = Kohana::$config->load('extasy')->admin_path_prefix;
Route::set('admin-feedback', trim($adminPrefix . 'contacts(/<action>(/<id>))'))->defaults(array('directory' => 'admin', 'controller' => 'feedback', 'action' => 'index'));
Route::set('site-contacts', 'contacts(/<action>)')->defaults(array('directory' => 'site', 'controller' => 'contacts', 'action' => 'index'));
Route::set('site-ajax', 'ajax(/<action>)')->defaults(array('directory' => 'site', 'controller' => 'ajax', 'action' => 'ajax_add_comment'));
开发者ID:ariol,项目名称:adminshop,代码行数:10,代码来源:init.php

示例10: defined

<?php

defined('SYSPATH') or die('No direct script access.');
if (!Route::cache()) {
    Route::set('b_settings', ADMIN . '/settings(/<action>)', ['action' => 'i18n'])->defaults(['directory' => 'Settings/Backend', 'controller' => 'page', 'action' => 'edit']);
}
开发者ID:eok8177,项目名称:shopCMS,代码行数:6,代码来源:init.php

示例11: Kohana_Log_File

 * - string   cache_dir   set the internal cache directory                   APPPATH/cache
 * - boolean  errors      enable or disable error handling                   TRUE
 * - boolean  profile     enable or disable internal profiling               TRUE
 * - boolean  caching     enable or disable internal caching                 FALSE
 */
Kohana::init(array('base_url' => '/', 'index_file' => FALSE, 'charset' => 'utf-8'));
/**
 * Attach the file write to logging. Multiple writers are supported.
 */
Kohana::$log->attach(new Kohana_Log_File(APPPATH . 'logs'));
/**
 * Attach a file reader to config. Multiple readers are supported.
 */
Kohana::$config->attach(new Kohana_Config_File());
/**
 * Enable modules. Modules are referenced by a relative or absolute path.
 */
Kohana::modules(array('database' => MODPATH . 'database', 'image' => MODPATH . 'image', 'orm' => MODPATH . 'orm', 'pagination' => MODPATH . 'pagination'));
/**
 * Set the routes. Each route must have a minimum of a name, a URI and a set of
 * defaults for the URI.
 */
Route::set('admin', 'admin(/<action>(/<id>))')->defaults(array('controller' => 'admin', 'action' => 'index'));
Route::set('captcha', 'captcha(/<action>)')->defaults(array('controller' => 'captcha', 'action' => 'default'));
Route::set('bg', 'background')->defaults(array('controller' => 'page', 'action' => 'background'));
Route::set('default', '(<page>(/<id>))')->defaults(array('controller' => 'page', 'action' => 'showpage'));
/**
 * Execute the main request. A source of the URI can be passed, eg: $_SERVER['PATH_INFO'].
 * If no source is specified, the URI will be automatically detected.
 */
echo Request::instance()->execute()->send_headers()->response;
开发者ID:purplexcite,项目名称:seagifts,代码行数:31,代码来源:bootstrap.php

示例12: defined

<?php

defined('SYSPATH') or die('No direct script access.');
Route::set('image', 'image/get/<file>', array('file' => '.+.(?:jpe?g|png|gif)'))->defaults(array('directory' => 'spot', 'controller' => 'image'));
开发者ID:peschee,项目名称:Spot_image,代码行数:4,代码来源:init.php

示例13: defined

<?php

defined('SYSPATH') or die('No direct script access.');
// Disable in CLI
if (defined("PHP_SAPI") && PHP_SAPI == 'cli') {
    return;
}
Route::set('logdelete', 'logs/delete/<year>/<month>/<logfile>', array('logfile' => '.*'))->defaults(array('controller' => 'Logs', 'action' => 'delete'));
Route::set('logviewer', 'logs/(<year>(/<month>(/<day>(/<level>))))')->defaults(array('controller' => 'Logs', 'action' => 'index'));
开发者ID:tscms,项目名称:logviewer,代码行数:9,代码来源:init.php

示例14: define

<?php

// If we're on the CLI then PHPUnit will already be loaded
if (class_exists('PHPUnit_Util_Filter', FALSE)) {
    Kohana_Tests::configure_enviroment();
    // Stop kohana from processing the request
    define('SUPPRESS_REQUEST', TRUE);
} else {
    if (Kohana_Tests::enabled()) {
        // People shouldn't be running unit tests on their production server
        // so we assume that this /could/ be a web ui request on the dev server
        // and include phpunit so that modules can add specific files to the blacklist
        require_once 'PHPUnit/Framework.php';
    }
}
Route::set('unittest', '(phpunit(/<action>(/<id>)))')->defaults(array('controller' => 'phpunit', 'action' => 'index'));
开发者ID:pcraciunoiu,项目名称:unittest,代码行数:16,代码来源:init.php

示例15: defined

<?php

defined('SYSPATH') or die('No direct script access.');
/**
 * Nexmo Data Provider
 *
 * @author     Ushahidi Team <team@ushahidi.com>
 * @package    DataProvider\Nexmo
 * @copyright  2013 Ushahidi
 * @license    http://www.gnu.org/copyleft/gpl.html GNU General Public License Version 3 (GPLv3)
 */
// Plugin Info
$plugin = array('name' => 'Nexmo', 'version' => '0.1', 'services' => array(Message_Type::SMS => TRUE, Message_Type::IVR => FALSE, Message_Type::EMAIL => FALSE, Message_Type::TWITTER => FALSE), 'options' => array('from' => array('label' => 'From', 'input' => 'text', 'description' => 'The from number', 'rules' => array('required')), 'secret' => array('label' => 'Secret', 'input' => 'text', 'description' => 'The secret value', 'rules' => array('required')), 'api_key' => array('label' => 'API Key', 'input' => 'text', 'description' => 'The API key', 'rules' => array('required')), 'api_secret' => array('label' => 'API secret', 'input' => 'text', 'description' => 'The API secret', 'rules' => array('required'))), 'links' => array('developer' => 'https://www.nexmo.com/', 'signup' => 'https://dashboard.nexmo.com/register'));
// Register the plugin
DataProvider::register_provider('nexmo', $plugin);
// Additional Routes
Route::set('nexmo_sms_callback_url', 'sms/nexmo(/<action>)')->defaults(array('directory' => 'Sms', 'controller' => 'Nexmo'));
开发者ID:gjorgiev,项目名称:platform,代码行数:17,代码来源:init.php


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