mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-09-08 04:22:40 +00:00
Making TaskCollection use App::import instead of goofy shell paths.
Moving files in the testsuite around to reflect changed paths.
This commit is contained in:
parent
8c63f155ba
commit
5737cf7877
7 changed files with 22 additions and 23 deletions
|
@ -27,6 +27,13 @@ class TaskCollection extends ObjectCollection {
|
|||
protected $_Shell;
|
||||
protected $_Dispatch;
|
||||
|
||||
/**
|
||||
* The directory inside each shell path that contains tasks.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $taskPathPrefix = 'tasks/';
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
|
@ -56,8 +63,9 @@ class TaskCollection extends ObjectCollection {
|
|||
$taskFile = Inflector::underscore($name);
|
||||
$taskClass = $name . 'Task';
|
||||
if (!class_exists($taskClass)) {
|
||||
$taskFile = $this->_getPath($taskFile);
|
||||
require_once $taskFile;
|
||||
if (!App::import('Shell', $plugin . $this->taskPathPrefix . $name)) {
|
||||
throw new MissingTaskFileException($taskFile . '.php');
|
||||
}
|
||||
if (!class_exists($taskClass)) {
|
||||
throw new MissingTaskClassException($taskClass);
|
||||
}
|
||||
|
@ -72,21 +80,4 @@ class TaskCollection extends ObjectCollection {
|
|||
return $this->_loaded[$name];
|
||||
}
|
||||
|
||||
/**
|
||||
* Find a task file on one of the paths.
|
||||
*
|
||||
* @param string $file Underscored name of the file to find missing .php
|
||||
* @return string Filename to the task
|
||||
* @throws MissingTaskFileException
|
||||
*/
|
||||
protected function _getPath($file) {
|
||||
foreach ($this->_Shell->shellPaths as $path) {
|
||||
$taskPath = $path . 'tasks' . DS . $file . '.php';
|
||||
if (file_exists($taskPath)) {
|
||||
return $taskPath;
|
||||
}
|
||||
}
|
||||
throw new MissingTaskFileException($file . '.php');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue