1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Gacela\Console; |
6
|
|
|
|
7
|
|
|
use Gacela\Console\Domain\FilenameSanitizer\FilenameSanitizer; |
8
|
|
|
use Gacela\Console\Infrastructure\Command\ListModulesCommand; |
9
|
|
|
use Gacela\Console\Infrastructure\Command\MakeFileCommand; |
10
|
|
|
use Gacela\Console\Infrastructure\Command\MakeModuleCommand; |
11
|
|
|
use Gacela\Framework\AbstractProvider; |
12
|
|
|
use Gacela\Framework\Container\Container; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* @method ConsoleConfig getConfig() |
16
|
|
|
*/ |
17
|
|
|
final class ConsoleProvider extends AbstractProvider |
18
|
|
|
{ |
19
|
|
|
public const COMMANDS = 'COMMANDS'; |
20
|
|
|
|
21
|
|
|
public const TEMPLATE_BY_FILENAME_MAP = 'TEMPLATE_FILENAME_MAP'; |
22
|
|
|
|
23
|
|
|
public function provideModuleDependencies(Container $container): void |
24
|
|
|
{ |
25
|
|
|
$this->addCommands($container); |
26
|
|
|
$this->addTemplateByFilenameMap($container); |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
private function addCommands(Container $container): void |
30
|
|
|
{ |
31
|
|
|
$container->set(self::COMMANDS, static fn (): array => [ |
32
|
|
|
new MakeFileCommand(), |
33
|
|
|
new MakeModuleCommand(), |
34
|
|
|
new ListModulesCommand(), |
35
|
|
|
]); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
private function addTemplateByFilenameMap(Container $container): void |
39
|
|
|
{ |
40
|
|
|
$container->set(self::TEMPLATE_BY_FILENAME_MAP, fn (): array => [ |
41
|
|
|
FilenameSanitizer::FACADE => $this->getConfig()->getFacadeMakerTemplate(), |
42
|
|
|
FilenameSanitizer::FACTORY => $this->getConfig()->getFactoryMakerTemplate(), |
43
|
|
|
FilenameSanitizer::CONFIG => $this->getConfig()->getConfigMakerTemplate(), |
44
|
|
|
FilenameSanitizer::PROVIDER => $this->getConfig()->getProviderMakerTemplate(), |
45
|
|
|
]); |
46
|
|
|
} |
47
|
|
|
} |
48
|
|
|
|