4 use DrupalCodeGenerator\ApplicationFactory;
5 use DrupalCodeGenerator\Command\Navigation;
6 use DrupalCodeGenerator\GeneratorDiscovery;
7 use DrupalCodeGenerator\Utils;
8 use Symfony\Component\Filesystem\Filesystem;
10 // The autoloader may have a different location if DCG is installed as a local
12 $autoloader = file_exists(__DIR__ . '/../vendor/autoload.php')
13 ? require __DIR__ . '/../vendor/autoload.php'
14 : require __DIR__ . '/../../../autoload.php';
16 // Create an application.
17 $application = ApplicationFactory::create();
19 // Discover generators.
20 $discovery = new GeneratorDiscovery(new Filesystem());
21 $commands_directories[] = ApplicationFactory::getRoot() . '/src/Command';
22 $home = Utils::getHomeDirectory();
23 if (file_exists($home . '/.dcg/Command')) {
24 $commands_directories[] = $home . '/.dcg/Command';
25 $autoloader->addPsr4('DrupalCodeGenerator\\', $home . '/.dcg');
27 $generators = $discovery->getGenerators($commands_directories);
28 $application->addCommands($generators);
30 // Add the navigation command.
31 $application->add(new Navigation($generators));
32 $application->setDefaultCommand('navigation');