Final Class Yiisoft\Config\Command\CopyCommand
| Inheritance | Yiisoft\Config\Command\CopyCommand » Composer\Command\BaseCommand |
|---|
CopyCommand copies the package configuration files from the vendor to the application.
Protected Methods
| Method | Description | Defined By |
|---|---|---|
| configure() | Yiisoft\Config\Command\CopyCommand | |
| execute() | Yiisoft\Config\Command\CopyCommand |
Method Details
| protected void configure ( ) |
protected function configure(): void
{
$this
->setName('yii-config-copy')
->setDescription('Copying package configuration files to the application.')
->setHelp('This command copies the package configuration files from the vendor to the application.')
->addArgument('package', InputArgument::REQUIRED, 'Package')
->addArgument('target', InputArgument::OPTIONAL, 'Target directory', '/')
->addArgument('files', InputArgument::OPTIONAL | InputArgument::IS_ARRAY, 'Files')
;
}
| protected integer execute ( \Symfony\Component\Console\Input\InputInterface $input, \Symfony\Component\Console\Output\OutputInterface $output ) | ||
| $input | \Symfony\Component\Console\Input\InputInterface | |
| $output | \Symfony\Component\Console\Output\OutputInterface | |
protected function execute(InputInterface $input, OutputInterface $output): int
{
/** @var string $package */
$package = $input->getArgument('package');
/** @var string $target */
$target = $input->getArgument('target');
/** @var string[] $selectedFileNames */
$selectedFileNames = $input->getArgument('files');
$builder = new PackageFilesProcess($this->requireComposer(), [$package]);
$filesystem = new Filesystem();
$targetPath = $builder
->paths()
->absolute(trim($target, '\/'));
$filesystem->ensureDirectoryExists($targetPath);
$prefix = str_replace('/', '-', $package);
foreach ($this->prepareFiles($builder->files(), $selectedFileNames) as $file) {
$filename = str_replace('/', '-', $file->filename());
$filesystem->copy($file->absolutePath(), "$targetPath/$prefix-$filename");
}
return 0;
}
Signup or Login in order to comment.