Fix #1383 Task list is empty

This commit is contained in:
Nicolas Le Goff
2013-07-31 16:06:21 +02:00
parent 7e3ca30674
commit 16c100ecbc

View File

@@ -14,6 +14,7 @@ use Alchemy\Phrasea\Application;
use Symfony\Component\Process\ProcessBuilder; use Symfony\Component\Process\ProcessBuilder;
use Symfony\Component\Process\PhpExecutableFinder; use Symfony\Component\Process\PhpExecutableFinder;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\Finder\Finder;
/** /**
* *
@@ -220,32 +221,28 @@ class task_manager
public static function getAvailableTasks() public static function getAvailableTasks()
{ {
$taskdir = array( $dirs = array(__DIR__ . "/period");
__DIR__ . "/period/",
__DIR__ . "/../../../config/classes/task/period/", if (is_dir($configDir = __DIR__ . "/../../../config/classes/task/period")) {
); $dirs[] = $configDir;
}
$tasks = array(); $tasks = array();
foreach ($taskdir as $path) { $finder = new Finder();
if (($hdir = @opendir($path)) != FALSE) {
$max = 9999;
while (($max-- > 0) && (($file = readdir($hdir)) !== false)) {
if (!is_file($path . '/' . $file) || substr($file, 0, 1) == "." || substr($file, -10) != ".php") {
continue;
}
$classname = 'task_period_' . substr($file, 0, strlen($file) - 10); foreach ($finder->files()->in($dirs)->name("*.php") as $file) {
$classname = 'task_period_' . $file->getBasename('.php');
try { try {
// $testclass = new $classname(null); if (class_exists($classname) && $classname::interfaceAvailable()) {
if ($classname::interfaceAvailable()) { $tasks[] = array(
$tasks[] = array("class" => $classname, "name" => $classname::getName(), "err" => null); "class" => $classname,
} "name" => $classname::getName(),
} catch (Exception $e) { "err" => null
);
}
} }
closedir($hdir); } catch (Exception $e) {
} }
} }