|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* MageSpec |
|
4
|
|
|
* |
|
5
|
|
|
* NOTICE OF LICENSE |
|
6
|
|
|
* |
|
7
|
|
|
* This source file is subject to the MIT License, that is bundled with this |
|
8
|
|
|
* package in the file LICENSE. |
|
9
|
|
|
* It is also available through the world-wide-web at this URL: |
|
10
|
|
|
* |
|
11
|
|
|
* http://opensource.org/licenses/MIT |
|
12
|
|
|
* |
|
13
|
|
|
* If you did not receive a copy of the license and are unable to obtain it |
|
14
|
|
|
* through the world-wide-web, please send an email |
|
15
|
|
|
* to <[email protected]> so we can send you a copy immediately. |
|
16
|
|
|
* |
|
17
|
|
|
* @category MageTest |
|
18
|
|
|
* @package PhpSpec_MagentoExtension |
|
19
|
|
|
* |
|
20
|
|
|
* @copyright Copyright (c) 2012-2013 MageTest team and contributors. |
|
21
|
|
|
*/ |
|
22
|
|
|
namespace MageTest\PhpSpec\MagentoExtension\Console\Command; |
|
23
|
|
|
|
|
24
|
|
|
use PhpSpec\Locator\ResourceManagerInterface; |
|
25
|
|
|
use PhpSpec\ServiceContainer; |
|
26
|
|
|
use Symfony\Component\Console\Command\Command; |
|
27
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
|
28
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
29
|
|
|
|
|
30
|
|
|
abstract class MageCommand extends Command |
|
31
|
|
|
{ |
|
32
|
|
|
/** |
|
33
|
|
|
* @var string |
|
34
|
|
|
*/ |
|
35
|
|
|
protected $validator; |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* @var string |
|
39
|
|
|
*/ |
|
40
|
|
|
protected $help; |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* @var string |
|
44
|
|
|
*/ |
|
45
|
|
|
protected $type; |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* @var ServiceContainer |
|
49
|
|
|
*/ |
|
50
|
|
|
private $container; |
|
51
|
|
|
|
|
52
|
|
|
public function __construct(ServiceContainer $container) |
|
53
|
|
|
{ |
|
54
|
|
|
$this->container = $container; |
|
55
|
|
|
|
|
56
|
|
|
parent::__construct(); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
protected function execute(InputInterface $input, OutputInterface $output) |
|
60
|
|
|
{ |
|
61
|
|
|
$alias = $input->getArgument('alias'); |
|
62
|
|
|
|
|
63
|
|
|
if ((bool) preg_match($this->validator, $alias) === false) { |
|
64
|
|
|
throw new \InvalidArgumentException($this->help); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
$this->container->configure(); |
|
68
|
|
|
|
|
69
|
|
|
$classname = $this->type . ':' . $alias; |
|
70
|
|
|
$resource = $this->container->get('locator.resource_manager')->createResource($classname); |
|
71
|
|
|
|
|
72
|
|
|
$this->container->get('code_generator')->generate($resource, 'specification'); |
|
73
|
|
|
} |
|
74
|
|
|
} |
|
75
|
|
|
|