-
-
Notifications
You must be signed in to change notification settings - Fork 419
/
Copy pathAbstractMaker.php
71 lines (62 loc) · 2.02 KB
/
AbstractMaker.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
/*
* This file is part of the Symfony MakerBundle package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Bundle\MakerBundle\Maker;
use Symfony\Bundle\MakerBundle\ConsoleStyle;
use Symfony\Bundle\MakerBundle\DependencyBuilder;
use Symfony\Bundle\MakerBundle\MakerInterface;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
/**
* Convenient abstract class for makers.
*/
abstract class AbstractMaker implements MakerInterface
{
/**
* @return void
*/
public function interact(InputInterface $input, ConsoleStyle $io, Command $command)
{
}
/**
* @return void
*/
protected function writeSuccessMessage(ConsoleStyle $io)
{
$io->newLine();
$io->writeln(' <bg=green;fg=white> </>');
$io->writeln(' <bg=green;fg=white> Success! </>');
$io->writeln(' <bg=green;fg=white> </>');
$io->newLine();
}
/** @param array<class-string, string> $dependencies */
protected function addDependencies(array $dependencies, ?string $message = null): string
{
$dependencyBuilder = new DependencyBuilder();
foreach ($dependencies as $class => $name) {
$dependencyBuilder->addClassDependency($class, $name);
}
return $dependencyBuilder->getMissingPackagesMessage(
static::getCommandName(),
$message
);
}
/**
* Get the help file contents needed for "setHelp()" of a maker.
*
* @param string $helpFileName the filename (omit path) of the help file located in config/help/
* e.g. MakeController.txt
*
* @internal
*/
final protected function getHelpFileContents(string $helpFileName): string
{
return file_get_contents(\sprintf('%s/config/help/%s', \dirname(__DIR__, 2), $helpFileName));
}
}