_Shell = $Shell; } /** * Loads/constructs a task. Will return the instance in the collection * if it already exists. * * @param string $task Task name to load * @param array $settings Settings for the task. * @param boolean $enable Whether or not this task should be enabled by default * @return Task A task object, Either the existing loaded task or a new one. * @throws MissingTaskFileException, MissingTaskClassException when the task could not be found */ public function load($task, $settings = array(), $enable = true) { list($plugin, $name) = pluginSplit($task, true); if (isset($this->_loaded[$name])) { return $this->_loaded[$name]; } $taskFile = Inflector::underscore($name); $taskClass = $name . 'Task'; App::uses($taskClass, 'Console/Command/Task'); if (!class_exists($taskClass)) { if (!class_exists($taskClass)) { throw new MissingTaskClassException($taskClass); } } $this->_loaded[$name] = new $taskClass( $this->_Shell->stdout, $this->_Shell->stderr, $this->_Shell->stdin ); if ($enable === true) { $this->_enabled[] = $name; } return $this->_loaded[$name]; } }