Skip to content

Commit

Permalink
Added option to select docroot (#436)
Browse files Browse the repository at this point in the history
  • Loading branch information
helios-ag authored Jan 29, 2021
1 parent c40b62f commit 0c35db5
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions src/Command/ElFinderInstallerCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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:
<info>public</info>
You can pass docroot:
<info>Where to install elfinder</info>
<info>php %command.full_name% --docroot=public_html</info>
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;
}
}

0 comments on commit 0c35db5

Please sign in to comment.