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


PHP Autoloader::add_namespaces方法代码示例

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


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

示例1: load

 /**
  * Loads the given module.  If a path is not given, then 'module_paths' is used.
  * It also accepts an array of modules as the first parameter.
  *
  * @param   string|array  $package  The module name or array of modules.
  * @param   string|null   $path     The path to the module
  * @return  bool  True on success
  * @throws  ModuleNotFoundException
  */
 public static function load($module, $path = null)
 {
     if (is_array($module)) {
         $result = true;
         foreach ($module as $mod => $path) {
             if (is_numeric($mod)) {
                 $mod = $path;
                 $path = null;
             }
             $result = $result and static::load($mod, $path);
         }
         return $result;
     }
     if (static::loaded($module)) {
         return;
     }
     // if no path is given, try to locate the module
     if ($path === null) {
         $paths = \Config::get('module_paths', array());
         if (!empty($paths)) {
             foreach ($paths as $modpath) {
                 if (is_dir($path = $modpath . strtolower($module) . DS)) {
                     break;
                 }
             }
         }
     } else {
         // make sure it's terminated properly
         $path = rtrim($path, DS) . DS;
     }
     // make sure the path exists
     if (!is_dir($path)) {
         throw new \ModuleNotFoundException("Module '{$module}' could not be found at '" . \Fuel::clean_path($path) . "'");
     }
     // determine the module namespace
     $ns = '\\' . ucfirst($module);
     // add the namespace to the autoloader
     \Autoloader::add_namespaces(array($ns => $path . 'classes' . DS), true);
     static::$modules[$module] = $path;
     return true;
 }
开发者ID:SainsburysTests,项目名称:sainsburys,代码行数:50,代码来源:module.php

示例2: add_module

 /**
  * Add module
  *
  * Registers a given module as a class prefix and returns the path to the
  * module. Won't register twice, will just return the path on a second call.
  *
  * @param	string	module name (lowercase prefix without underscore)
  * @param	bool	whether it is an loaded package
  */
 public static function add_module($name, $loaded = false)
 {
     if (!($path = Autoloader::namespace_path('\\' . ucfirst($name)))) {
         $paths = \Config::get('module_paths', array());
         if (empty($paths)) {
             return false;
         }
         foreach ($paths as $modpath) {
             if (is_dir($mod_check_path = $modpath . strtolower($name) . DS)) {
                 $path = $mod_check_path;
                 $ns = '\\' . ucfirst($name);
                 Autoloader::add_namespaces(array($ns => $path . 'classes' . DS), true);
                 break;
             }
         }
     } else {
         // strip the classes directory, we need the module root
         $path = substr($path, 0, -8);
     }
     if ($loaded) {
         // add the module path
         static::add_path($path);
         // get the path for this modules namespace
         if ($path = Autoloader::namespace_path('\\' . ucfirst($name))) {
             // add the namespace path too
             static::add_path($path);
         }
     }
     return $path;
 }
开发者ID:huglester,项目名称:fuel-uploadify,代码行数:39,代码来源:fuel.php

示例3: add_module

 /**
  * Add module
  *
  * Registers a given module as a class prefix and returns the path to the
  * module. Won't register twice, will just return the path on a second call.
  *
  * @param   string  module name (lowercase prefix without underscore)
  * @return  string  the path that was loaded
  */
 public static function add_module($name)
 {
     if (!($path = \Autoloader::namespace_path('\\' . ucfirst($name)))) {
         $paths = \Config::get('module_paths', array());
         if (!empty($paths)) {
             foreach ($paths as $modpath) {
                 if (is_dir($mod_check_path = $modpath . strtolower($name) . DS)) {
                     $path = $mod_check_path;
                     $ns = '\\' . ucfirst($name);
                     \Autoloader::add_namespaces(array($ns => $path . 'classes' . DS), true);
                     break;
                 }
             }
         }
         // throw an exception if a non-existent module has been added
         if (!isset($ns)) {
             throw new \FuelException('Trying to add a non-existent module "' . $name . '"');
         }
     } else {
         // strip the classes directory, we need the module root
         $path = substr($path, 0, -8);
     }
     return $path;
 }
开发者ID:phabos,项目名称:fuel-core,代码行数:33,代码来源:fuel.php

示例4: isset

<?php

// Bootstrap the framework DO NOT edit this
require COREPATH . 'bootstrap.php';
Autoloader::add_namespaces(array());
Autoloader::add_classes(array('DbModel\\DataTrain' => APPPATH . 'classes/model/msgboardDB.php'));
// Register the autoloader
Autoloader::register();
/**
 * Your environment.  Can be set to any of the following:
 *
 * Fuel::DEVELOPMENT
 * Fuel::TEST
 * Fuel::STAGING
 * Fuel::PRODUCTION
 */
Fuel::$env = isset($_SERVER['FUEL_ENV']) ? $_SERVER['FUEL_ENV'] : Fuel::DEVELOPMENT;
// Initialize the framework with the config file.
Fuel::init('config.php');
开发者ID:seiran1944,项目名称:slate,代码行数:19,代码来源:bootstrap.php

示例5: add_module

	/**
	 * Add module
	 *
	 * Registers a given module as a class prefix and returns the path to the
	 * module. Won't register twice, will just return the path on a second call.
	 *
	 * @param   string  module name (lowercase prefix without underscore)
	 * @return  string  the path that was loaded
	 */
	public static function add_module($name)
	{
		if ( ! $path = \Autoloader::namespace_path('\\'.ucfirst($name)))
		{
			$paths = \Config::get('module_paths', array());

			if (empty($paths))
			{
				return false;
			}

			foreach ($paths as $modpath)
			{
				if (is_dir($mod_check_path = $modpath.strtolower($name).DS))
				{
					$path = $mod_check_path;
					$ns = '\\'.ucfirst($name);
					\Autoloader::add_namespaces(array(
						$ns					=> $path.'classes'.DS,
					), true);
					break;
				}
			}
		}
		else
		{
			// strip the classes directory, we need the module root
			$path = substr($path,0, -8);
		}

		return $path;
	}
开发者ID:novius,项目名称:core,代码行数:41,代码来源:fuel.php

示例6: add_module

	/**
	 * Add module
	 *
	 * Registers a given module as a class prefix and returns the path to the
	 * module. Won't register twice, will just return the path on a second call.
	 *
	 * @param	string	module name (lowercase prefix without underscore)
	 * @param	bool	whether it is an active package
	 */
	public static function add_module($name, $active = false)
	{
		$paths = \Config::get('module_paths', array());

		if (empty($paths))
		{
			return false;
		}

		$path = Autoloader::namespace_path('\\'.ucfirst($name));

		if ( ! $path)
		{
			foreach ($paths as $path)
			{
				if (is_dir($mod_check_path = $path.strtolower($name).DS))
				{
					$path = $mod_check_path;
					$ns = '\\'.ucfirst($name);
					Autoloader::add_namespaces(array(
						$ns					=> $path.'classes'.DS,
						$ns.'\\Model'		=> $path.'classes'.DS.'model'.DS,
						$ns.'\\Controller'	=> $path.'classes'.DS.'controller'.DS,
					), true);
					Autoloader::add_namespace_aliases(array(
						$ns.'\\Controller'	=> 'Fuel\\App',
						$ns.'\\Model'		=> 'Fuel\\App',
						$ns					=> 'Fuel\\App',
					), true);
					break;
				}
			}
		}

		// not found
		if ( ! $path)
		{
			return false;
		}

		// add the module path
		static::add_path($path);

		// get the path for this modules namespace
		$path = Autoloader::namespace_path('\\'.ucfirst($name));

		// Active modules get their path prefixed and routes loaded
		if ($active)
		{
			static::add_path($path, true);

			// We want active modules to be able to have their own routes, so we reload routes.
			\Route::load_routes(true);
			return $path;
		}

		static::add_path($path);
		return $path;
	}
开发者ID:ralf57,项目名称:fuel,代码行数:68,代码来源:fuel.php

示例7: gettext

<?php

\Autoloader::add_namespaces(array('Erp' => __DIR__ . DS . 'classes' . DS), true);
$menu = \Menu_Admin::instance('indigo');
$menu->add(array(array('name' => gettext('ERP'), 'icon' => 'glyphicon glyphicon-file', 'sort' => 15, 'children' => array(array('name' => gettext('Products'), 'url' => \Uri::admin(false) . 'erp/stock/product'), array('name' => gettext('Manufacturers'), 'url' => \Uri::admin(false) . 'erp/stock/manufacturer')))));
开发者ID:indigophp,项目名称:indigo-erp-stock,代码行数:5,代码来源:bootstrap.php


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