0 follower

Final Class Yiisoft\Config\Command\CopyCommand

InheritanceYiisoft\Config\Command\CopyCommand » Composer\Command\BaseCommand

CopyCommand copies the package configuration files from the vendor to the application.

Method Details

Hide inherited methods

configure() protected method

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')
    ;
}

            
execute() protected method

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;
}