|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
|
|
4
|
|
|
namespace Deployee\Plugins\ShellTasks; |
|
5
|
|
|
|
|
6
|
|
|
|
|
7
|
|
|
use Deployee\Components\Config\ConfigInterface; |
|
8
|
|
|
use Deployee\Components\Container\ContainerInterface; |
|
9
|
|
|
use Deployee\Components\Dependency\ContainerResolver; |
|
10
|
|
|
use Deployee\Components\Plugins\PluginInterface; |
|
11
|
|
|
use Deployee\Plugins\Deploy\Dispatcher\DispatcherCollection; |
|
12
|
|
|
use Deployee\Plugins\Deploy\Helper\TaskCreationHelper; |
|
13
|
|
|
use Deployee\Plugins\ShellTasks\Definitions\ShellTaskDefinition; |
|
14
|
|
|
use Deployee\Plugins\ShellTasks\Dispatcher\ShellTaskDefinitionDispatcher; |
|
15
|
|
|
use Deployee\Plugins\ShellTasks\Helper\ExecutableFinder; |
|
16
|
|
|
|
|
17
|
|
|
class ShellTasksPlugin implements PluginInterface |
|
18
|
|
|
{ |
|
19
|
|
|
/** |
|
20
|
|
|
* @param ContainerInterface $container |
|
21
|
|
|
*/ |
|
22
|
|
|
public function boot(ContainerInterface $container) |
|
23
|
|
|
{ |
|
24
|
|
|
$container->set(ExecutableFinder::class, function(ContainerInterface $container){ |
|
25
|
|
|
/* @var ConfigInterface $config */ |
|
26
|
|
|
$config = $container->get(ConfigInterface::class); |
|
27
|
|
|
|
|
28
|
|
|
return new ExecutableFinder($config->get('shell.aliases', [])); |
|
29
|
|
|
}); |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* @param ContainerInterface $container |
|
34
|
|
|
* @throws \ReflectionException |
|
35
|
|
|
*/ |
|
36
|
|
|
public function configure(ContainerInterface $container) |
|
37
|
|
|
{ |
|
38
|
|
|
/* @var TaskCreationHelper $taskCreationHelper */ |
|
39
|
|
|
$taskCreationHelper = $container->get(TaskCreationHelper::class); |
|
40
|
|
|
$taskCreationHelper->addAlias('shell', ShellTaskDefinition::class); |
|
41
|
|
|
|
|
42
|
|
|
/* @var ContainerResolver $resolver */ |
|
43
|
|
|
$resolver = $container->get(ContainerResolver::class); |
|
44
|
|
|
|
|
45
|
|
|
/* @var ShellTaskDefinitionDispatcher $taskDispatcher */ |
|
46
|
|
|
$taskDispatcher = $resolver->createInstance(ShellTaskDefinitionDispatcher::class); |
|
47
|
|
|
|
|
48
|
|
|
/* @var DispatcherCollection $dispatcherCollection */ |
|
49
|
|
|
$dispatcherCollection = $container->get(DispatcherCollection::class); |
|
50
|
|
|
$dispatcherCollection->addDispatcher($taskDispatcher); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
} |