Skip to content

Instantly share code, notes, and snippets.

@kurozumi
Created January 21, 2021 06:15
Show Gist options
  • Save kurozumi/187182412fb13314f4ca7ca0f609dd3b to your computer and use it in GitHub Desktop.
Save kurozumi/187182412fb13314f4ca7ca0f609dd3b to your computer and use it in GitHub Desktop.
InstallerCommand
<?php
namespace Customize\Command;
use Eccube\Command\PluginCommandTrait;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\Finder\Finder;
use Symfony\Component\Process\Process;
class InstallerCommand extends Command
{
protected static $defaultName = 'customize:install';
use PluginCommandTrait;
protected function configure()
{
$this
->setDescription('Load customize data fixtures to database.');
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new SymfonyStyle($input, $output);
$process = new Process('bin/console eccube:install -n');
$process->mustRun();
$io->text($process->getOutput());
$finder = Finder::create()
->in(__DIR__ . '/Fixtures')
->name('*.sql');
foreach ($finder->getIterator() as $fixture) {
$process = new Process('bin/console doctrine:database:import '.$fixture->getPathname());
$process->mustRun();
$io->text($process->getOutput());
}
$this->clearCache($io);
$io->success('success.');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment