This commit is contained in:
Kamil Kuzminski 2017-04-14 19:20:08 +00:00 committed by GitHub
commit 66535b14ab
2 changed files with 35 additions and 2 deletions

View file

@ -42,6 +42,7 @@ class TaskFactory
{
$this->runtime = $runtime;
$this->loadBuiltInTasks();
$this->loadCustomTasks();
}
/**
@ -114,4 +115,34 @@ class TaskFactory
}
}
}
/**
* Load the custom tasks
*
* @throws \RuntimeException
*/
protected function loadCustomTasks()
{
$config = $this->runtime->getConfiguration();
if (!isset($config['custom_tasks'])) {
return;
}
if (!is_array($config['custom_tasks'])) {
throw new \RuntimeException('The "custom_tasks" configuration must be an array');
}
foreach ($config['custom_tasks'] as $class) {
if (class_exists($class)) {
$reflex = new ReflectionClass($class);
if ($reflex->isInstantiable()) {
$task = new $class();
if ($task instanceof AbstractTask) {
$this->add($task);
}
}
}
}
}
}

View file

@ -14,7 +14,9 @@ magephp:
- composer/install
- composer/dump-autoload
on-deploy:
- Mage\Tests\Task\CustomTask
- custom
on-release:
post-release:
post-deploy:
post-deploy:
custom_tasks:
- Mage\Tests\Task\CustomTask