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


PHP Fuel::list_files方法代码示例

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


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

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

示例2: _discover_tasks

 /**
  * Find all of the task classes in the system and use reflection to discover the
  * commands we can call.
  *
  * @return array $taskname => array($taskmethods)
  **/
 protected static function _discover_tasks()
 {
     $result = array();
     $files = \Fuel::list_files('tasks');
     if (count($files) > 0) {
         foreach ($files as $file) {
             $task_name = str_replace('.php', '', basename($file));
             $class_name = '\\Fuel\\Tasks\\' . $task_name;
             require $file;
             $reflect = new \ReflectionClass($class_name);
             // Ensure we only pull out the public methods
             $methods = $reflect->getMethods(\ReflectionMethod::IS_PUBLIC);
             $result[$task_name] = array();
             if (count($methods) > 0) {
                 foreach ($methods as $method) {
                     $result[$task_name][] = $method->name;
                 }
             }
         }
     }
     return $result;
 }
开发者ID:469306621,项目名称:Languages,代码行数:28,代码来源:refine.php


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