diff --git a/src/Command/ElFinderInstallerCommand.php b/src/Command/ElFinderInstallerCommand.php index 125d3e3..59b8e1b 100644 --- a/src/Command/ElFinderInstallerCommand.php +++ b/src/Command/ElFinderInstallerCommand.php @@ -6,7 +6,9 @@ use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Style\SymfonyStyle; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; use Symfony\Component\Filesystem\Filesystem; @@ -37,21 +39,37 @@ protected function configure(): void { $this ->setDescription('Copies elfinder assets to public directory') - ; + ->addOption('docroot', NULL, InputOption::VALUE_OPTIONAL, 'Website document root.', 'public') + ->setHelp(<<<'EOF' +Default docroot: + public + +You can pass docroot: + Where to install elfinder + php %command.full_name% --docroot=public_html +EOF + ); } protected function execute(InputInterface $input, OutputInterface $output): int { + $io = new SymfonyStyle($input, $output); + $dr = $input->getOption('docroot'); + $io->title('elFinder Installer'); + $io->comment(sprintf('Trying to install elfinder to %s directory', $dr)); + $rootDir = $this->parameterBag->get('kernel.project_dir'); - $publicDir = $rootDir.'/public/bundles/fmelfinder'; + + $publicDir = sprintf("%s/%s/bundles/fmelfinder", $rootDir, $dr); + + $io->note(sprintf('Starting to install elfinder to %s folder', $publicDir)); $this->fileSystem->mirror($rootDir . '/' . self::ELFINDER_CSS_DIR, $publicDir.'/css'); $this->fileSystem->mirror($rootDir . '/' . self::ELFINDER_IMG_DIR, $publicDir.'/img'); $this->fileSystem->mirror($rootDir . '/' . self::ELFINDER_JS_DIR, $publicDir.'/js'); $this->fileSystem->mirror($rootDir . '/' . self::ELFINDER_SOUNDS_DIR, $publicDir.'/sounds'); - $output->writeln('elFinder assets successfully installed'); - + $io->success('elFinder assets successfully installed'); return 0; } }