-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
162 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,17 +4,17 @@ | |
|
||
use Doctrine\Bundle\PHPCRBundle\DataFixtures\PHPCRExecutor; | ||
use Doctrine\Common\DataFixtures\Purger\PHPCRPurger; | ||
use Doctrine\ODM\PHPCR\Tools\Console\Helper\DocumentManagerHelper; | ||
use InvalidArgumentException; | ||
use PHPCR\Util\Console\Command\BaseCommand; | ||
use Symfony\Bridge\Doctrine\DataFixtures\ContainerAwareLoader; | ||
use Symfony\Bundle\FrameworkBundle\Console\Application; | ||
use Symfony\Component\Console\Command\Command; | ||
use Symfony\Component\Console\Helper\DialogHelper; | ||
use Symfony\Component\Console\Helper\QuestionHelper; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Input\InputOption; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
use Symfony\Component\Console\Question\ConfirmationQuestion; | ||
use Symfony\Component\DependencyInjection\ContainerAwareTrait; | ||
use Symfony\Component\HttpKernel\KernelInterface; | ||
|
||
/** | ||
* Command to load PHPCR-ODM fixtures. | ||
|
@@ -24,7 +24,7 @@ | |
* @author Jonathan H. Wage <[email protected]> | ||
* @author Daniel Leech <[email protected]> | ||
*/ | ||
class LoadFixtureCommand extends Command | ||
class LoadFixtureCommand extends BaseCommand | ||
{ | ||
use ContainerAwareTrait; | ||
|
||
|
@@ -65,28 +65,24 @@ protected function configure(): void | |
protected function execute(InputInterface $input, OutputInterface $output): int | ||
{ | ||
$dmName = $input->getOption('dm'); // defaults to null | ||
$application = $this->getApplication(); | ||
if (!$application instanceof Application) { | ||
throw new \InvalidArgumentException('Expected to find '.Application::class.' but got '. | ||
($application ? \get_class($application) : null)); | ||
} | ||
DoctrineCommandHelper::setApplicationDocumentManager( | ||
$this->getApplication(), | ||
$application, | ||
$dmName | ||
); | ||
|
||
$dm = $this->getHelperSet()->get('phpcr')->getDocumentManager(); | ||
$dm = $this->getPhpcrHelper()->getDocumentManager(); | ||
$noInitialize = $input->getOption('no-initialize'); | ||
|
||
if ($input->isInteractive() && !$input->getOption('append')) { | ||
$question = '<question>Careful, database will be purged. Do you want to continue Y/N ?</question>'; | ||
$default = false; | ||
if ($this->getHelperSet()->has('question')) { | ||
/** @var $questionHelper QuestionHelper */ | ||
$questionHelper = $this->getHelperSet()->get('question'); | ||
$question = new ConfirmationQuestion($question, $default); | ||
$result = $questionHelper->ask($input, $output, $question); | ||
} else { | ||
/** @var $dialog DialogHelper */ | ||
$dialog = $this->getHelperSet()->get('dialog'); | ||
$result = $dialog->askConfirmation($output, $question, $default); | ||
} | ||
|
||
$questionHelper = $this->getQuestionHelper(); | ||
$question = new ConfirmationQuestion($question, false); | ||
$result = $questionHelper->ask($input, $output, $question); | ||
if (!$result) { | ||
return 0; | ||
} | ||
|
@@ -96,8 +92,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int | |
if ($dirOrFile) { | ||
$paths = \is_array($dirOrFile) ? $dirOrFile : [$dirOrFile]; | ||
} else { | ||
/** @var $kernel KernelInterface */ | ||
$kernel = $this->getApplication()->getKernel(); | ||
$kernel = $application->getKernel(); | ||
$projectDir = method_exists($kernel, 'getRootDir') ? $kernel->getRootDir() : $kernel->getProjectDir().'/src'; | ||
$paths = [$projectDir.'/DataFixtures/PHPCR']; | ||
foreach ($kernel->getBundles() as $bundle) { | ||
|
@@ -137,4 +132,12 @@ protected function execute(InputInterface $input, OutputInterface $output): int | |
|
||
return 0; | ||
} | ||
|
||
protected function getPhpcrHelper(): DocumentManagerHelper | ||
{ | ||
$helper = parent::getPhpcrHelper(); | ||
\assert($helper instanceof DocumentManagerHelper); | ||
|
||
return $helper; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.