1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @author stev leibelt <[email protected]> |
4
|
|
|
* @since 2015-07-08 |
5
|
|
|
*/ |
6
|
|
|
|
7
|
|
|
namespace NetBazzlineZfCliGenerator\Controller\Console; |
8
|
|
|
|
9
|
|
|
use Net\Bazzline\Component\ProcessPipe\PipeInterface; |
10
|
|
|
use Zend\ServiceManager\Exception\InvalidArgumentException; |
11
|
|
|
use Zend\ServiceManager\ServiceLocatorInterface; |
12
|
|
|
use ZfConsoleHelper\Controller\Console\AbstractConsoleControllerFactory; |
13
|
|
|
|
14
|
|
|
class IndexControllerFactory extends AbstractConsoleControllerFactory |
15
|
|
|
{ |
16
|
|
|
/** |
17
|
|
|
* Create service |
18
|
|
|
* |
19
|
|
|
* @param ServiceLocatorInterface $serviceLocator |
20
|
|
|
* |
21
|
|
|
* @return mixed|IndexController |
22
|
|
|
*/ |
23
|
|
|
public function createService(ServiceLocatorInterface $serviceLocator) |
24
|
|
|
{ |
25
|
|
|
$controller = new IndexController(); |
26
|
|
|
$serviceLocator = $this->transformIntoServiceManager($serviceLocator); |
27
|
|
|
|
28
|
|
|
/** @var array|\Zend\Config\Config $configuration */ |
29
|
|
|
$configuration = $serviceLocator->get('Config'); |
30
|
|
|
$key = 'net_bazzline_zf_cli_generator'; |
31
|
|
|
|
32
|
|
|
if (!isset($configuration[$key])) { |
33
|
|
|
throw new InvalidArgumentException ( |
34
|
|
|
'expected configuration key "' . $key . '" not found' |
35
|
|
|
); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** @var PipeInterface $cliGenerator */ |
39
|
|
|
$cliGenerator = $serviceLocator->get('NetBazzlineCliGeneratorGenerateCliContent'); |
40
|
|
|
/** @var PipeInterface $configurationGenerator */ |
41
|
|
|
$configurationGenerator = $serviceLocator->get('NetBazzlineCliGeneratorGenerateConfigurationContent'); |
42
|
|
|
|
43
|
|
|
$configuration = $configuration[$key]; |
44
|
|
|
$pathToApplication = $configuration['application']['path'] . |
45
|
|
|
DIRECTORY_SEPARATOR . |
46
|
|
|
$configuration['application']['name']; |
47
|
|
|
$pathToAutoload = $configuration['autoload']['path'] . |
48
|
|
|
DIRECTORY_SEPARATOR . |
49
|
|
|
$configuration['autoload']['name']; |
50
|
|
|
$pathToConfiguration = $configuration['configuration']['target']['path'] . |
51
|
|
|
DIRECTORY_SEPARATOR . |
52
|
|
|
$configuration['configuration']['target']['name']; |
53
|
|
|
$pathToCli = $configuration['cli']['target']['path'] . |
54
|
|
|
DIRECTORY_SEPARATOR . |
55
|
|
|
$configuration['cli']['target']['name']; |
56
|
|
|
$prefix = $configuration['cli']['prefix']; |
57
|
|
|
|
58
|
|
|
$controller->injectGenerateConfigurationProcessPipe($configurationGenerator); |
59
|
|
|
$controller->injectGenerateCliProcessPipe($cliGenerator); |
60
|
|
|
$controller->injectPathToApplication($pathToApplication); |
61
|
|
|
$controller->injectPathToAutoload($pathToAutoload); |
62
|
|
|
$controller->injectPathToConfiguration($pathToConfiguration); |
63
|
|
|
$controller->injectPathToCli($pathToCli); |
64
|
|
|
$controller->injectPrefix($prefix); |
65
|
|
|
|
66
|
|
|
return $controller; |
67
|
|
|
} |
68
|
|
|
} |
69
|
|
|
|