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


PHP Fuel::module_exists方法代码示例

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


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

示例1: find_controller

 /**
  * Find the controller that matches the route requested
  *
  * @param	Route		the given Route object
  * @return	mixed		the match array or false
  */
 protected static function find_controller($match)
 {
     // First port of call: request for a module?
     if (\Fuel::module_exists($match->segments[0])) {
         // make the module known to the autoloader
         \Fuel::add_module($match->segments[0]);
         $segments = $match->segments;
         // first check if the controller is in a directory.
         $match->module = array_shift($segments);
         $match->directory = count($segments) ? array_shift($segments) : null;
         $match->controller = count($segments) ? array_shift($segments) : $match->module;
         // does the module controller exist?
         if (class_exists(ucfirst($match->module) . '\\Controller_' . ucfirst($match->directory) . '_' . ucfirst($match->controller))) {
             $match->action = count($segments) ? array_shift($segments) : null;
             $match->method_params = $segments;
             return $match;
         }
         $segments = $match->segments;
         // then check if it's a module controller
         $match->module = array_shift($segments);
         $match->directory = null;
         $match->controller = count($segments) ? array_shift($segments) : $match->module;
         // does the module controller exist?
         if (class_exists(ucfirst($match->module) . '\\Controller_' . ucfirst($match->controller))) {
             $match->action = count($segments) ? array_shift($segments) : null;
             $match->method_params = $segments;
             return $match;
         }
         $segments = $match->segments;
         // do we have a module controller with the same name as the module?
         if ($match->controller != $match->module) {
             array_shift($segments);
             $match->controller = $match->module;
             if (class_exists(ucfirst($match->module) . '\\Controller_' . ucfirst($match->controller))) {
                 $match->action = count($segments) ? array_shift($segments) : null;
                 $match->method_params = $segments;
                 return $match;
             }
         }
     }
     $segments = $match->segments;
     // It's not a module, first check if the controller is in a directory.
     $match->directory = array_shift($segments);
     $match->controller = count($segments) ? array_shift($segments) : $match->directory;
     if (class_exists('Controller_' . ucfirst($match->directory) . '_' . ucfirst($match->controller))) {
         $match->action = count($segments) ? array_shift($segments) : null;
         $match->method_params = $segments;
         return $match;
     }
     $segments = $match->segments;
     // It's not in a directory, so check for app controllers
     $match->directory = null;
     $match->controller = count($segments) ? array_shift($segments) : $match->directory;
     // We first want to check if the controller is in a directory.
     if (class_exists('Controller_' . ucfirst($match->controller))) {
         $match->action = count($segments) ? array_shift($segments) : null;
         $match->method_params = $segments;
         return $match;
     }
     // none of the above. I give up. We've found ziltch...
     $match->action = null;
     $match->controller = null;
     return $match;
 }
开发者ID:469306621,项目名称:Languages,代码行数:70,代码来源:router.php

示例2: parse_match

 /**
  * Find the controller that matches the route requested
  *
  * @param	Route  $match  the given Route object
  * @return	mixed  the match array or false
  */
 protected static function parse_match($match)
 {
     $namespace = '';
     $segments = $match->segments;
     $module = false;
     // First port of call: request for a module?
     if (\Fuel::module_exists($segments[0])) {
         // make the module known to the autoloader
         \Fuel::add_module($segments[0]);
         $match->module = array_shift($segments);
         $namespace .= ucfirst($match->module) . '\\';
         $module = $match->module;
     }
     if ($info = static::parse_segments($segments, $namespace, $module)) {
         $match->controller = $info['controller'];
         $match->action = $info['action'];
         $match->method_params = $info['method_params'];
         return $match;
     } else {
         return null;
     }
 }
开发者ID:quickpacket,项目名称:noclayer,代码行数:28,代码来源:router.php

示例3: __construct

 /**
  * Creates the new Request object by getting a new URI object, then parsing
  * the uri with the Route class.
  *
  * Usage:
  *
  *     $request = new Request('foo/bar');
  *
  * @param   string  the uri string
  * @param   bool    whether or not to route the URI
  * @return  void
  */
 public function __construct($uri, $route = true)
 {
     $this->uri = new \Uri($uri);
     // check if a module was requested
     if (count($this->uri->segments) and $modpath = \Fuel::module_exists($this->uri->segments[0])) {
         // check if the module has routes
         if (file_exists($modpath .= 'config/routes.php')) {
             // load and add the module routes
             $modroutes = \Config::load(\Fuel::load($modpath), $this->uri->segments[0] . '_routes');
             foreach ($modroutes as $name => $modroute) {
                 switch ($name) {
                     case '_root_':
                         // map the root to the module default controller/method
                         $name = $this->uri->segments[0];
                         break;
                     case '_404_':
                         // do not touch the 404 route
                         break;
                     default:
                         // prefix the route with the module name if it isn't done yet
                         if (strpos($name, $this->uri->segments[0] . '/') !== 0 and $name != $this->uri->segments[0]) {
                             $name = $this->uri->segments[0] . '/' . $name;
                         }
                         break;
                 }
                 \Config::set('routes.' . $name, $modroute);
             }
             // update the loaded list of routes
             \Router::add(\Config::get('routes'));
         }
     }
     $this->route = \Router::process($this, $route);
     if (!$this->route) {
         return;
     }
     if ($this->route->module !== null) {
         $this->module = $this->route->module;
         \Fuel::add_module($this->module);
         $this->add_path(\Fuel::module_exists($this->module));
     }
     $this->directory = $this->route->directory;
     $this->controller = $this->route->controller;
     $this->action = $this->route->action;
     $this->method_params = $this->route->method_params;
     $this->named_params = $this->route->named_params;
 }
开发者ID:469306621,项目名称:Languages,代码行数:58,代码来源:request.php

示例4: __construct

 /**
  * Creates the new Request object by getting a new URI object, then parsing
  * the uri with the Route class.
  *
  * Usage:
  *
  *     $request = new Request('foo/bar');
  *
  * @param   string  the uri string
  * @param   bool    whether or not to route the URI
  * @return  void
  */
 public function __construct($uri, $route = true)
 {
     $this->uri = new \Uri($uri);
     logger(\Fuel::L_INFO, 'Creating a new Request with URI = "' . $this->uri->uri . '"', __METHOD__);
     // check if a module was requested
     if (count($this->uri->segments) and $module_path = \Fuel::module_exists($this->uri->segments[0])) {
         // check if the module has routes
         if (is_file($module_path .= 'config/routes.php')) {
             $module = $this->uri->segments[0];
             // load and add the module routes
             $module_routes = \Fuel::load($module_path);
             $prepped_routes = array();
             foreach ($module_routes as $name => $_route) {
                 if ($name === '_root_') {
                     $name = $module;
                 } elseif (strpos($name, $module . '/') !== 0 and $name != $module and $name !== '_404_') {
                     $name = $module . '/' . $name;
                 }
                 $prepped_routes[$name] = $_route;
             }
             // update the loaded list of routes
             \Router::add($prepped_routes, null, true);
         }
     }
     $this->route = \Router::process($this, $route);
     if (!$this->route) {
         return;
     }
     $this->module = $this->route->module;
     $this->controller = $this->route->controller;
     $this->action = $this->route->action;
     $this->method_params = $this->route->method_params;
     $this->named_params = $this->route->named_params;
     if ($this->route->module !== null) {
         $this->add_path(\Fuel::module_exists($this->module));
     }
 }
开发者ID:quickpacket,项目名称:noclayer,代码行数:49,代码来源:request.php

示例5: __construct

	/**
	 * Creates the new Request object by getting a new URI object, then parsing
	 * the uri with the Route class.
	 *
	 * Usage:
	 *
	 *     $request = new Request('foo/bar');
	 *
	 * @param   string  the uri string
	 * @param   bool    whether or not to route the URI
	 * @return  void
	 */
	public function __construct($uri, $route = true)
	{
		$this->uri = new \Uri($uri);

		// check if a module was requested
		if (count($this->uri->segments) and $modpath = \Fuel::module_exists($this->uri->segments[0]))
		{
			// check if the module has custom routes
			if (file_exists($modpath .= 'config/routes.php'))
			{
				// load and add the routes
				\Config::load(\Fuel::load($modpath), 'routes');
				\Router::add(\Config::get('routes'));
			}
		}

		$this->route = \Router::process($this, $route);

		if ( ! $this->route)
		{
			return false;
		}

		if ($this->route->module !== null)
		{
			$this->module = $this->route->module;
			\Fuel::add_module($this->module);
			$this->add_path(\Fuel::module_exists($this->module));
		}

		$this->directory = $this->route->directory;
		$this->controller = $this->route->controller;
		$this->action = $this->route->action;
		$this->method_params = $this->route->method_params;
		$this->named_params = $this->route->named_params;
	}
开发者ID:novius,项目名称:core,代码行数:48,代码来源:request.php


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