1
|
|
|
<?php |
2
|
|
|
declare(strict_types=1); |
3
|
|
|
|
4
|
|
|
/** |
5
|
|
|
* This file is part of phpDocumentor. |
6
|
|
|
* |
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
8
|
|
|
* file that was distributed with this source code. |
9
|
|
|
* |
10
|
|
|
* @author Mike van Riel <[email protected]> |
11
|
|
|
* @copyright 2010-2018 Mike van Riel / Naenius (http://www.naenius.com) |
12
|
|
|
* @license http://www.opensource.org/licenses/mit-license.php MIT |
13
|
|
|
* @link http://phpdoc.org |
14
|
|
|
*/ |
15
|
|
|
|
16
|
|
|
namespace phpDocumentor\Console\Command\Template; |
17
|
|
|
|
18
|
|
|
use Symfony\Component\Console\Command\Command; |
19
|
|
|
use \Symfony\Component\Console\Input\InputInterface; |
20
|
|
|
use \Symfony\Component\Console\Output\OutputInterface; |
21
|
|
|
use phpDocumentor\Transformer\Template\Factory; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* Lists all templates known to phpDocumentor. |
25
|
|
|
*/ |
26
|
|
|
class ListCommand extends Command |
27
|
|
|
{ |
28
|
|
|
/** @var Factory Template factory providing all known template definitions */ |
29
|
|
|
private $factory; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Initializes this command with its dependencies. |
33
|
|
|
*/ |
34
|
1 |
|
public function __construct(Factory $factory) |
35
|
|
|
{ |
36
|
1 |
|
parent::__construct('template:list'); |
37
|
|
|
|
38
|
1 |
|
$this->factory = $factory; |
39
|
1 |
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Initializes this command and sets the name, description, options and arguments. |
43
|
|
|
*/ |
44
|
1 |
|
protected function configure(): void |
45
|
|
|
{ |
46
|
1 |
|
$this->setName('template:list') |
47
|
1 |
|
->setDescription( |
48
|
1 |
|
'Displays a listing of all available templates in phpDocumentor' |
49
|
|
|
) |
50
|
1 |
|
->setHelp( |
51
|
|
|
<<<HELP |
52
|
1 |
|
This task outputs a list of templates as available in phpDocumentor. |
53
|
|
|
Please mind that custom templates which are situated outside phpDocumentor are not |
54
|
|
|
shown in this listing. |
55
|
|
|
HELP |
56
|
|
|
); |
57
|
1 |
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* Retrieves all template names from the Template Factory and sends those to stdout. |
61
|
|
|
*/ |
62
|
1 |
|
protected function execute(InputInterface $input, OutputInterface $output): int |
63
|
|
|
{ |
64
|
1 |
|
$output->writeln('Available templates:'); |
65
|
1 |
|
foreach ($this->factory->getAllNames() as $template_name) { |
66
|
1 |
|
$output->writeln('* ' . $template_name); |
67
|
|
|
} |
68
|
|
|
|
69
|
1 |
|
$output->writeln(''); |
70
|
|
|
|
71
|
1 |
|
return 0; |
72
|
|
|
} |
73
|
|
|
} |
74
|
|
|
|