1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* Copyright (c) Manero Contributors. All rights reserved. |
4
|
|
|
* |
5
|
|
|
* Licensed under the MIT License. See LICENSE.md file in the |
6
|
|
|
* project root for full license information. |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
namespace Manero\Command; |
10
|
|
|
|
11
|
|
|
use Manero\Creator\TraitCreator; |
12
|
|
|
use Manero\Service\ConvertZendExpressiveService; |
13
|
|
|
use Symfony\Component\Console\Command\Command; |
14
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
15
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
16
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
17
|
|
|
|
18
|
|
|
class ConvertZendExpressiveCommand extends Command |
19
|
|
|
{ |
20
|
|
|
protected function configure() |
21
|
|
|
{ |
22
|
|
|
$this->setName('convert:zend-expressive') |
23
|
|
|
->setDescription('Convert Zend Expressive configuration to disco') |
24
|
|
|
->setHelp(' |
25
|
|
|
This task will convert a ZendExpressive 3 configuration to a Trait |
26
|
|
|
usable by Disco. |
27
|
|
|
|
28
|
|
|
Call it right within your Expressive-Apps home-folder like this: |
29
|
|
|
|
30
|
|
|
php /path/to/manero.phar convert:zend-expressive config/config.php |
31
|
|
|
') |
32
|
|
|
->addArgument('configurationFile', InputArgument::REQUIRED, 'The Configuration-File to convert') |
33
|
|
|
; |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
protected function execute(InputInterface $input, OutputInterface $output) |
37
|
|
|
{ |
38
|
|
|
$configFile = $input->getArgument('configurationFile'); |
39
|
|
|
|
40
|
|
|
try { |
41
|
|
|
$configuration = require $configFile; |
42
|
|
|
} catch (\Throwable $exception) { |
43
|
|
|
$output->writeln($exception->getMessage()); |
44
|
|
|
return; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
$outputFile = 'ManeroConfigTrait.php'; |
48
|
|
|
|
49
|
|
|
$service = new ConvertZendExpressiveService( |
50
|
|
|
$configuration['dependencies'], |
51
|
|
|
new TraitCreator(getcwd() . '/' . $outputFile) |
52
|
|
|
); |
53
|
|
|
|
54
|
|
|
$service(); |
55
|
|
|
|
56
|
|
|
$output->writeln('Created file "ManeroConfigTrait.php'); |
57
|
|
|
$output->writeln('Copy that file to your Disco-Project, adapt the namespace and include it via "use"'); |
58
|
|
|
} |
59
|
|
|
} |
60
|
|
|
|