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


PHP Fuel::load方法代码示例

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


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

示例1: load

 /**
  * Loads the given package.  If a path is not given, then PKGPATH is used.
  * It also accepts an array of packages as the first parameter.
  *
  * @param   string|array  $package  The package name or array of packages.
  * @param   string|null   $path     The path to the package
  * @return  bool  True on success
  * @throws  PackageNotFoundException
  */
 public static function load($package, $path = null)
 {
     if (is_array($package)) {
         foreach ($package as $pkg) {
             $path = null;
             if (is_array($pkg)) {
                 list($pkg, $path) = $pkg;
             }
             static::load($pkg, $path);
         }
         return false;
     }
     if (static::loaded($package)) {
         return;
     }
     // Load it from PKGPATH if no path was given.
     if ($path === null) {
         $path = PKGPATH . $package . DS;
     }
     if (!is_dir($path)) {
         throw new \PackageNotFoundException("Package '{$package}' could not be found at '" . \Fuel::clean_path($path) . "'");
     }
     \Finder::instance()->add_path($path, 1);
     \Fuel::load($path . 'bootstrap.php');
     static::$packages[$package] = $path;
     return true;
 }
开发者ID:quickpacket,项目名称:noclayer,代码行数:36,代码来源:package.php

示例2: load

 /**
  * Loads the given package.
  * If a path is not given, if will search through
  * the defined package_paths. If not defined, then PKGPATH is used.
  * It also accepts an array of packages as the first parameter.
  *
  * @param string|array $package
  *        	The package name or array of packages.
  * @param string|null $path
  *        	The path to the package
  * @return bool True on success
  * @throws PackageNotFoundException
  */
 public static function load($package, $path = null)
 {
     if (is_array($package)) {
         foreach ($package as $pkg => $path) {
             if (is_numeric($pkg)) {
                 $pkg = $path;
                 $path = null;
             }
             static::load($pkg, $path);
         }
         return false;
     }
     if (static::loaded($package)) {
         return;
     }
     // if no path is given, try to locate the package
     if ($path === null) {
         $paths = \Config::get('package_paths', array());
         empty($paths) and $paths = array(PKGPATH);
         if (!empty($paths)) {
             foreach ($paths as $modpath) {
                 if (is_dir($path = $modpath . strtolower($package) . DS)) {
                     break;
                 }
             }
         }
     }
     if (!is_dir($path)) {
         throw new \PackageNotFoundException("Package '{$package}' could not be found at '" . \Fuel::clean_path($path) . "'");
     }
     \Finder::instance()->add_path($path, 1);
     \Fuel::load($path . 'bootstrap.php');
     static::$packages[$package] = $path;
     return true;
 }
开发者ID:vienbk91,项目名称:fuelphp17,代码行数:48,代码来源:package.php

示例3: config

    public static function config($args, $build = true)
    {
        $args = self::_clear_args($args);
        $file = strtolower(array_shift($args));
        $config = array();
        // load the config
        if ($paths = \Finder::search('config', $file, '.php', true)) {
            // Reverse the file list so that we load the core configs first and
            // the app can override anything.
            $paths = array_reverse($paths);
            foreach ($paths as $path) {
                $config = \Fuel::load($path) + $config;
            }
        }
        unset($path);
        // We always pass in fields to a config, so lets sort them out here.
        foreach ($args as $conf) {
            // Each paramater for a config is seperated by the : character
            $parts = explode(":", $conf);
            // We must have the 'name:value' if nothing else!
            if (count($parts) >= 2) {
                $config[$parts[0]] = $parts[1];
            }
        }
        $overwrite = \Cli::option('o') or \Cli::option('overwrite');
        $content = <<<CONF
<?php
/**
 * Fuel is a fast, lightweight, community driven PHP5 framework.
 *
 * @package\t\tFuel
 * @version\t\t1.0
 * @author\t\tFuel Development Team
 * @license\t\tMIT License
 * @copyright\t2011 Fuel Development Team
 * @link\t\thttp://fuelphp.com
 */


CONF;
        $content .= 'return ' . str_replace('  ', "\t", var_export($config, true)) . ';';
        $content .= <<<CONF


/* End of file {$file}.php */
CONF;
        $path = APPPATH . 'config' . DS . $file . '.php';
        if (!$overwrite and is_file($path)) {
            throw new Exception("APPPATH/config/{$file}.php already exist, please use -overwrite option to force update");
        }
        $path = pathinfo($path);
        try {
            \File::update($path['dirname'], $path['basename'], $content);
            \Cli::write("Created config: APPPATH/config/{$file}.php", 'green');
        } catch (\InvalidPathException $e) {
            throw new Exception("Invalid basepath, cannot update at " . APPPATH . "config" . DS . "{$file}.php");
        } catch (\FileAccessException $e) {
            throw new Exception(APPPATH . "config" . DS . $file . ".php could not be written.");
        }
    }
开发者ID:reganhimself,项目名称:KeeleProgrammers,代码行数:60,代码来源:generate.php

示例4: load

 public static function load($file, $group = null, $reload = false)
 {
     if (!is_array($file) && array_key_exists($file, static::$loaded_files) and !$reload) {
         return false;
     }
     $config = array();
     if (is_array($file)) {
         $config = $file;
     } elseif ($paths = \Fuel::find_file('config', $file, '.php', true)) {
         // Reverse the file list so that we load the core configs first and
         // the app can override anything.
         $paths = array_reverse($paths);
         foreach ($paths as $path) {
             $config = \Fuel::load($path) + $config;
         }
     }
     if ($group === null) {
         static::$items = $reload ? $config : static::$items + $config;
     } else {
         $group = $group === true ? $file : $group;
         if (!isset(static::$items[$group]) or $reload) {
             static::$items[$group] = array();
         }
         static::$items[$group] = static::$items[$group] + $config;
     }
     if (!is_array($file)) {
         static::$loaded_files[$file] = true;
     }
     return $config;
 }
开发者ID:bryanheo,项目名称:FuelPHP-Auth-AJAX,代码行数:30,代码来源:config.php

示例5: load

	public static function load($file, $group = null)
	{
		$lang = array();

		// Use the current language, failing that use the fallback language
		foreach (array(\Config::get('language'), static::$fallback) as $language)
		{
			if ($path = \Fuel::find_file('lang/'.$language, $file, '.php', true))
			{
				$lang = array();
				foreach ($path as $p)
				{
					$lang = $lang + \Fuel::load($p);
				}
				break;
			}
		}

		if ($group === null)
		{
			static::$lines = static::$lines + $lang;
		}
		else
		{
			if ( ! isset(static::$lines[$group]))
			{
				static::$lines[$group] = array();
			}
			static::$lines[$group] = static::$lines[$group] + $lang;
		}
	}
开发者ID:nasumi,项目名称:fuel,代码行数:31,代码来源:lang.php

示例6: get

 /**
  * Get stencil data.
  *
  * @return  mixed   returns the array or string on success or false on failure
  */
 public static function get($stencil_name, $key = null)
 {
     $stencil_path = STENCILSPATH . $stencil_name . DS . 'config.php';
     if (!File::file_exists($stencil_path)) {
         return false;
     }
     if (!($stencil_data = \Fuel::load($stencil_path))) {
         return false;
     }
     // return value if key found
     if (isset($key)) {
         if (isset($stencil_data[$key])) {
             return $stencil_data[$key];
         } else {
             return false;
         }
     }
     // build inflections replacement array
     $tbl_singular = Table::get('crud.TBL_SINGULAR');
     $tbl_plural = Table::get('crud.TBL_PLURAL');
     if ($tbl_prefix = Table::get('crud.TBL_PREFIX')) {
         $pfx_path = str_replace('_', DS, $tbl_prefix);
         $tbl_singular = str_replace($tbl_prefix, $pfx_path, $tbl_singular);
         $tbl_plural = str_replace($tbl_prefix, $pfx_path, $tbl_plural);
     }
     $inflections = array(':SINGULAR' => $tbl_singular, ':PLURAL' => $tbl_plural);
     // make the replacements
     foreach ($stencil_data['files'] as $key => $value) {
         $stencil_data['files'][$key]['output_path'] = str_replace(array_keys($inflections), array_values($inflections), $value['output_path']);
     }
     return $stencil_data;
 }
开发者ID:niceboy120,项目名称:crude,代码行数:37,代码来源:stencil.php

示例7: load

 /**
  * Load a language file
  *
  * @param   string
  * @param   string|null  name of the group to load to, null for global
  */
 public static function load($file, $group = null, $language = null)
 {
     $languages = static::$fallback;
     array_unshift($languages, $language ?: \Config::get('language'));
     $lines = array();
     foreach ($languages as $lang) {
         if ($path = \Finder::search('lang/' . $lang, $file, '.php', true)) {
             foreach ($path as $p) {
                 $lines = \Arr::merge(\Fuel::load($p), $lines);
             }
             break;
         }
     }
     if ($group === null) {
         static::$lines = \Arr::merge($lines, static::$lines);
     } else {
         $group = $group === true ? $file : $group;
         if (!isset(static::$lines[$group])) {
             static::$lines[$group] = array();
         }
         static::$lines[$group] = \Arr::merge($lines, static::$lines[$group]);
     }
 }
开发者ID:reganhimself,项目名称:KeeleProgrammers,代码行数:29,代码来源:lang.php

示例8: config

    public static function config($args)
    {
        $file = strtolower(array_shift($args));
        if (empty($file)) {
            throw new Exception('No config filename has been provided.');
        }
        $config = array();
        // load the config
        if ($paths = \Finder::search('config', $file, '.php', true)) {
            // Reverse the file list so that we load the core configs first and
            // the app can override anything.
            $paths = array_reverse($paths);
            foreach ($paths as $path) {
                $config = \Fuel::load($path) + $config;
            }
        }
        unset($path);
        // We always pass in fields to a config, so lets sort them out here.
        foreach ($args as $conf) {
            // Each paramater for a config is seperated by the : character
            $parts = explode(":", $conf);
            // We must have the 'name:value' if nothing else!
            if (count($parts) >= 2) {
                $config[$parts[0]] = $parts[1];
            }
        }
        $overwrite = (\Cli::option('o') or \Cli::option('overwrite'));
        // strip whitespace and add tab
        $export = str_replace(array('  ', 'array ('), array("\t", 'array('), var_export($config, true));
        $content = '<?php' . PHP_EOL . PHP_EOL . 'return ' . $export . ';';
        $content .= <<<CONF


/* End of file {$file}.php */
CONF;
        $module = \Cli::option('module', \Cli::option('m'));
        // add support for `php oil g config module::file arg1:value1`
        if (strpos($file, '::') !== false) {
            list($module, $file) = explode('::', $file);
        }
        // get the namespace path (if available)
        if (!empty($module) and $path = \Autoloader::namespace_path('\\' . ucfirst($module))) {
            // strip the classes directory as we need the module root
            // and construct the filename
            $path = substr($path, 0, -8) . 'config' . DS . $file . '.php';
            $path_name = "\\" . ucfirst($module) . '::';
        } elseif (!empty($module)) {
            throw new Exception("{$module} need to be loaded first, please use config always_load.modules.");
        } else {
            $path = APPPATH . 'config' . DS . $file . '.php';
            $path_name = 'APPPATH/';
        }
        if (!$overwrite and is_file($path)) {
            throw new Exception("{$path_name}/config/{$file}.php already exist, please use --overwrite option to force update");
        }
        $path = pathinfo($path);
        try {
            \File::update($path['dirname'], $path['basename'], $content);
            \Cli::write("Created config: {$path_name}config/{$file}.php", 'green');
        } catch (\InvalidPathException $e) {
            throw new Exception("Invalid basepath, cannot update at " . $path_name . "config" . DS . "{$file}.php");
        } catch (\FileAccessException $e) {
            throw new Exception($path_name . "config" . DS . $file . ".php could not be written.");
        }
    }
开发者ID:takawasitobi,项目名称:pembit,代码行数:65,代码来源:generate.php

示例9: __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
  * @param   string  request method
  * @return  void
  */
 public function __construct($uri, $route = true, $method = null)
 {
     $this->uri = new \Uri($uri);
     $this->method = $method;
     logger(\Fuel::L_INFO, 'Creating a new Request with URI = "' . $uri . '"', __METHOD__);
     // check if a module was requested
     if (count($this->uri->segments()) and $module_path = \Module::exists($this->uri->get_segment(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(\Module::exists($this->module));
     }
 }
开发者ID:rysk92,项目名称:fuelphpbase,代码行数:51,代码来源:request.php

示例10: load_file

 /**
  * Loads in the given file and parses it.
  *
  * @param   string  $file  File to load
  * @return  array
  */
 protected function load_file($file)
 {
     return \Fuel::load($file);
 }
开发者ID:takawasitobi,项目名称:pembit,代码行数:10,代码来源:php.php

示例11: __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

示例12: unload

 /**
  * Unloads a module from the stack.
  *
  * @param   string  $module  The module name
  * @return  void
  */
 public static function unload($module)
 {
     // we can only unload a loaded module
     if (isset(static::$modules[$module])) {
         $path = static::$modules[$module];
         if (is_file($path .= 'config/routes.php')) {
             // load and add the module routes
             $module_routes = \Fuel::load($path);
             $route_names = 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;
                 }
                 $route_names[] = $name;
             }
             // delete the defined module routes
             \Router::delete($route_names);
         }
     }
     // delete this module
     unset(static::$modules[$module]);
 }
开发者ID:SainsburysTests,项目名称:sainsburys,代码行数:30,代码来源:module.php

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