123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- <?php
- declare(strict_types = 1);
- namespace Fgm\Drupal\Composer;
- use Composer\Command\BaseCommand;
- use Symfony\Component\Console\Input\InputInterface;
- use Symfony\Component\Console\Output\OutputInterface;
- abstract class BaseBuilderCommand extends BaseCommand
- {
-
- const ARG_FILE = 'file';
- protected function getBuilderConfig(): array
- {
- $conf = $this->getComposer()->getPackage()->getExtra()[Builder::NAME] ?? [];
- return $conf;
- }
- protected function getSettingsPath(): string
- {
- $settingsPath = getcwd() . "/settings";
- return $settingsPath;
- }
-
- public function validateTemplateName(InputInterface $input, OutputInterface $output): array {
- $file = $input->getArgument(static::ARG_FILE);
- $conf = $this->getBuilderConfig();
- $templateName = $conf['templates'][$file] ?? '';
- if (empty($templateName)) {
- $output->writeln(sprintf(
- 'Could not build file %s: no such template in composer.json extra section',
- $file
- ));
- return ["", 1];
- }
- return [$templateName, 0];
- }
- }
|