示例#1
0
 public function test_task_from_class_method()
 {
     $klass = "DB_Schema";
     $this->assertEquals('db:schema', NamingUtil::task_from_class_name($klass));
 }
示例#2
0
 private function load_all_tasks($task_dir)
 {
     if (!is_dir($task_dir)) {
         throw new Exception(sprintf("Task dir: %s does not exist", $task_dir));
         return false;
     }
     $files = scandir($task_dir);
     $regex = '/^class\\.(\\w+)\\.php$/';
     foreach ($files as $f) {
         //skip over invalid files
         if ($f == '.' || $f == ".." || !preg_match($regex, $f, $matches)) {
             continue;
         }
         require_once $task_dir . '/' . $f;
         $task_name = NamingUtil::task_from_class_name($matches[1]);
         $klass = NamingUtil::class_from_file_name($f);
         $this->register_task($task_name, new $klass($this->get_adapter()));
     }
 }