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


PHP Fuel::find_file方法代码示例

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


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

示例1: run

	public static function run($task, $args)
	{
		// Just call and run() or did they have a specific method in mind?
		list($task, $method)=array_pad(explode(':', $task), 2, 'run');

		$task = ucfirst(strtolower($task));

		if ( ! $file = \Fuel::find_file('tasks', $task))
		{
			throw new \Exception('Well that didnt work...');
			return;
		}

		require $file;

		$task = '\\Fuel\\Tasks\\'.$task;

		$new_task = new $task;

		// The help option hs been called, so call help instead
		if (\Cli::option('help') && is_callable(array($new_task, 'help')))
		{
			$method = 'help';
		}

		if ($return = call_user_func_array(array($new_task, $method), $args))
		{
			\Cli::write($return);
		}
	}
开发者ID:nasumi,项目名称:fuel,代码行数:30,代码来源:refine.php

示例2: save

    public static function save($file, $config)
    {
        if (!is_array($config)) {
            if (!isset(static::$items[$config])) {
                return false;
            }
            $config = static::$items[$config];
        }
        $content = <<<CONF
<?php
/**
 * Fuel
 *
 * 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 = \Fuel::find_file('config', $file, '.php') or $path[0] = APPPATH . 'config' . DS . $file . '.php';
        $path = pathinfo($path[0]);
        return File::update($path['dirname'], $path['basename'], $content);
    }
开发者ID:bryanheo,项目名称:FuelPHP-Auth-AJAX,代码行数:35,代码来源:config.php

示例3: 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

示例4: run

 public static function run($task, $args)
 {
     // Make sure something is set
     if ($task === null or $task === 'help') {
         static::help();
         return;
     }
     // Just call and run() or did they have a specific method in mind?
     list($task, $method) = array_pad(explode(':', $task), 2, 'run');
     $task = ucfirst(strtolower($task));
     // Find the task
     if (!($file = \Fuel::find_file('tasks', $task))) {
         throw new Exception(sprintf('Task "%s" does not exist.', $task));
         return;
     }
     require $file;
     $task = '\\Fuel\\Tasks\\' . $task;
     $new_task = new $task();
     // The help option hs been called, so call help instead
     if (\Cli::option('help') && is_callable(array($new_task, 'help'))) {
         $method = 'help';
     }
     if ($return = call_user_func_array(array($new_task, $method), $args)) {
         \Cli::write($return);
     }
 }
开发者ID:huglester,项目名称:fuel-uploadify,代码行数:26,代码来源:refine.php

示例5: 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 = \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;
            }
        }
        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') || \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 (\File_Exception $e) {
            throw new Exception("APPPATH/config/{$file}.php could not be written.");
        }
    }
开发者ID:huzairy,项目名称:feedmalaya,代码行数:58,代码来源:generate.php

示例6: to

 /**
  * passes the data to the template and returns the result
  *
  * @param 	string 	$template_file	the template file used to structure the data
  * @return 	array	the restructured data
  */
 public function to($template)
 {
     $template_folder = \Config::get('structure.templates_folder');
     $template_path = \Fuel::find_file($template_folder, $template);
     if (!$template_path) {
         throw new \Fuel_Exception('The requested template could not be found: ' . \Fuel::clean_path($file));
     }
     $data = static::capture($template_path, $this->_data);
     return static::capture($template_path, $this->_data);
 }
开发者ID:JaapRood,项目名称:fuel-structure,代码行数:16,代码来源:structure.php

示例7: save

    public static function save($file, $config)
    {
        if (!is_array($config)) {
            if (!isset(static::$items[$config])) {
                return false;
            }
            $config = static::$items[$config];
        }
        $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)) . ';';
        if (!($path = \Fuel::find_file('config', $file, '.php'))) {
            if ($pos = strripos($file, '::')) {
                // get the namespace path
                if ($path = \Autoloader::namespace_path('\\' . ucfirst(substr($file, 0, $pos)))) {
                    // strip the namespace from the filename
                    $file = substr($file, $pos + 2);
                    // strip the classes directory as we need the module root
                    // and construct the filename
                    $path = substr($path, 0, -8) . 'config' . DS . $file . '.php';
                } else {
                    // invalid namespace requested
                    return false;
                }
            }
        }
        $content .= <<<CONF



CONF;
        // make sure we have a fallback
        $path or $path = APPPATH . 'config' . DS . $file . '.php';
        $path = pathinfo($path);
        return File::update($path['dirname'], $path['basename'], $content);
    }
开发者ID:NateRadebaugh,项目名称:core,代码行数:49,代码来源:config.php

示例8: 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:nasumi,项目名称:fuel,代码行数:42,代码来源:config.php

示例9: run

 public static function run($task, $args)
 {
     // Make sure something is set
     if ($task === null or $task === 'help') {
         static::help();
         return;
     }
     // Just call and run() or did they have a specific method in mind?
     list($task, $method) = array_pad(explode(':', $task), 2, 'run');
     $task = ucfirst(strtolower($task));
     // Find the task
     if (!($file = \Fuel::find_file('tasks', $task))) {
         $files = \Fuel::list_files('tasks');
         $possibilities = array();
         foreach ($files as $file) {
             $possible_task = pathinfo($file, \PATHINFO_FILENAME);
             $difference = levenshtein($possible_task, $task);
             $possibilities[$difference] = $possible_task;
         }
         ksort($possibilities);
         if ($possibilities and current($possibilities) <= 5) {
             throw new Exception(sprintf('Task "%s" does not exist. Did you mean "%s"?', strtolower($task), current($possibilities)));
         } else {
             throw new Exception(sprintf('Task "%s" does not exist.', strtolower($task)));
         }
         return;
     }
     require $file;
     $task = '\\Fuel\\Tasks\\' . $task;
     $new_task = new $task();
     // The help option hs been called, so call help instead
     if (\Cli::option('help') && is_callable(array($new_task, 'help'))) {
         $method = 'help';
     }
     if ($return = call_user_func_array(array($new_task, $method), $args)) {
         \Cli::write($return);
     }
 }
开发者ID:bryanheo,项目名称:FuelPHP-Auth-AJAX,代码行数:38,代码来源:refine.php

示例10: set_filename

 /**
  * Sets the view filename.
  *
  *     $view->set_filename($file);
  *
  * @param   string  view filename
  * @return  View
  * @throws  Fuel_Exception
  */
 public function set_filename($file)
 {
     // set find_file's one-time-only search paths
     \Fuel::$volatile_paths = $this->request_paths;
     // locate the view file
     if (($path = \Fuel::find_file('views', $file, '.' . $this->extension, false, false)) === false) {
         throw new \Fuel_Exception('The requested view could not be found: ' . \Fuel::clean_path($file));
     }
     // Store the file path locally
     $this->_file = $path;
     return $this;
 }
开发者ID:469306621,项目名称:Languages,代码行数:21,代码来源:view.php

示例11: load

 public static function load($class)
 {
     $class = ltrim($class, '\\');
     $namespaced = ($pos = strripos($class, '\\')) !== false;
     if (empty(static::$auto_initialize)) {
         static::$auto_initialize = $class;
     }
     if (array_key_exists($class, static::$classes)) {
         include str_replace('/', DS, static::$classes[$class]);
         static::_init_class($class);
         return true;
     } elseif (!$namespaced and $class_name = static::is_core_class($class)) {
         include str_replace('/', DS, static::$classes[$class_name]);
         static::alias_to_namespace($class_name);
         static::_init_class($class);
         return true;
     } elseif (!$namespaced) {
         $file_path = str_replace('_', DS, $class);
         $file_path = \Fuel::find_file('classes', $file_path);
         if ($file_path !== false) {
             require $file_path;
             if (!class_exists($class, false) && class_exists($class_name = 'Fuel\\Core\\' . $class, false)) {
                 static::alias_to_namespace($class_name);
             }
             static::_init_class($class);
             return true;
         }
     } else {
         // need to stick the trimed \ back on...
         $namespace = '\\' . substr($class, 0, $pos);
         foreach (static::$namespaces as $ns => $path) {
             if (strncmp($ns, $namespace, $ns_len = strlen($ns)) === 0) {
                 $class_no_ns = substr($class, $pos + 1);
                 $file_path = strtolower($path . substr($namespace, strlen($ns) + 1) . DS . str_replace('_', DS, $class_no_ns) . '.php');
                 if (is_file($file_path)) {
                     // Fuel::$path_cache[$class] = $file_path;
                     // Fuel::$paths_changed = true;
                     require $file_path;
                     static::_init_class($class);
                     return true;
                 }
             }
         }
     }
     return false;
 }
开发者ID:netspencer,项目名称:fuel,代码行数:46,代码来源:autoloader.php

示例12: load

	public static function load($class)
	{
		$class = ltrim($class, '\\');
		$namespaced = strpos($class, '\\') !== false;

		if (empty(static::$auto_initialize))
		{
			static::$auto_initialize = $class;
		}
		if (array_key_exists($class, static::$classes))
		{
			include str_replace('/', DS, static::$classes[$class]);
			static::_init_class($class);
			return true;
		}
		elseif ( ! $namespaced and array_key_exists($class_name = 'Fuel\\Core\\'.$class, static::$classes))
		{
			include str_replace('/', DS, static::$classes[$class_name]);
			static::alias_to_namespace($class_name);
			static::_init_class($class);
			return true;
		}
		elseif ( ! $namespaced)
		{
			$file_path = str_replace('_', DS, $class);
			$file_path = \Fuel::find_file('classes', $file_path);
			if ($file_path !== false)
			{
				require $file_path;
				static::_init_class($class);
				return true;
			}
		}
		else
		{
			$file_path = str_replace('_', DS, ltrim(strrchr(strtolower($class), '\\'), '\\'));
			$file_path = \Fuel::find_file('', $file_path);
			if ($file_path !== false)
			{
				require $file_path;
				static::_init_class($class);
				return true;
			}
		}
		return false;
	}
开发者ID:ralf57,项目名称:fuel,代码行数:46,代码来源:autoloader.php

示例13: set_filename

	/**
	 * Sets the view filename.
	 *
	 *     $view->set_filename($file);
	 *
	 * @param   string  view filename
	 * @return  View
	 * @throws  Fuel_Exception
	 */
	public function set_filename($file)
	{
		if (($path = \Fuel::find_file('views', $file, '.'.$this->extension, false, false)) === false)
		{
			throw new \Fuel_Exception('The requested view could not be found: '.\Fuel::clean_path($file));
		}

		// Store the file path locally
		$this->_file = $path;

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


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