src/Samurai/Component/Task/Processor.php
public function find($name = null)
    {
        $tasks = [];

        foreach ($this->application->getAppPaths() as $path) {
            $files = $this->finder->path($path['dir'] . DS . 'Task')->recursive()->name('*TaskList.php')->find();
            foreach ($files as $file) {
                $task_path = substr($file, strlen($path['dir'] . DS . 'Task' . DS), - strlen('TaskList.php'));
                $task_name = join(':', array_map('lcfirst', explode(DS, $task_path)));

                $class_name = $file->getClassName();
                if (! class_exists($class_name)) continue;

                $refletion = new ReflectionClass($class_name);
                if (! $refletion->isInstantiable()) continue;

                $taskList = $refletion->newInstance();
                $taskList->setName($task_name);

                foreach ($taskList->getTasks() as $task) {
                    $tasks[] = $task;
                }
            }
        }

        if ($name) {
            $tasks = array_filter($tasks, function($task) use ($name) {
                return strpos($task->getName(), $name) === 0;
            });
        }

        return $tasks;
    }
public function find($name = null)
    {
        $tasks = [];

        foreach ($this->application->getAppPaths() as $path) {
            $files = $this->finder->path($path['dir'] . DS . 'Task')->recursive()->name('*TaskList.php')->find();
            foreach ($files as $file) {
                $task_path = substr($file, strlen($path['dir'] . DS . 'Task' . DS), - strlen('TaskList.php'));
                $task_name = join(':', array_map('lcfirst', explode(DS, $task_path)));

                $class_name = $file->getClassName();
                if (! class_exists($class_name)) continue;

                $refletion = new ReflectionClass($class_name);
                if (! $refletion->isInstantiable()) continue;

                $taskList = $refletion->newInstance();
                $taskList->setName($task_name);

                foreach ($taskList->getTasks() as $task) {
                    $tasks[] = $task;
                }
            }
        }

        if ($name) {
            $tasks = array_filter($tasks, function($task) use ($name) {
                return strpos($task->getName(), $name) === 0;
            });
        }

        return $tasks;
    }
public function find ( $ name = null ) { $ tasks = [ ] ; foreach ( $ this -> application -> getAppPaths ( ) as $ path ) { $ files = $ this -> finder -> path ( $ path [ 'dir' ] . DS . 'Task' ) -> recursive ( ) -> name ( '*TaskList.php' ) -> find ( ) ; foreach ( $ files as $ file ) { $ task_path = substr ( $ file , strlen ( $ path [ 'dir' ] . DS . 'Task' . DS ) , - strlen ( 'TaskList.php' ) ) ; $ task_name = join ( ':' , array_map ( 'lcfirst' , explode ( DS , $ task_path ) ) ) ; $ class_name = $ file -> getClassName ( ) ; if ( ! class_exists ( $ class_name ) ) continue ; $ refletion = new ReflectionClass ( $ class_name ) ; if ( ! $ refletion -> isInstantiable ( ) ) continue ; $ taskList = $ refletion -> newInstance ( ) ; $ taskList -> setName ( $ task_name ) ; foreach ( $ taskList -> getTasks ( ) as $ task ) { $ tasks [ ] = $ task ; } } } if ( $ name ) { $ tasks = array_filter ( $ tasks , function ( $ task ) use ( $ name ) { return strpos ( $ task -> getName ( ) , $ name ) === 0 ; } ) ; } return $ tasks ; }
find task.

@param   string  $name
find task .