vendor/doctrine/phpcr-bundle/src/Command/NodeDumpCommand.php line 18

Open in your IDE?
  1. <?php
  2. namespace Doctrine\Bundle\PHPCRBundle\Command;
  3. use PHPCR\Util\Console\Command\NodeDumpCommand as BaseDumpCommand;
  4. use PHPCR\Util\Console\Helper\PhpcrConsoleDumperHelper;
  5. use Symfony\Component\Console\Input\InputInterface;
  6. use Symfony\Component\Console\Input\InputOption;
  7. use Symfony\Component\Console\Output\OutputInterface;
  8. use Symfony\Component\DependencyInjection\ContainerAwareInterface;
  9. use Symfony\Component\DependencyInjection\ContainerInterface;
  10. /**
  11.  * Wrapper to use this command in the symfony console with multiple sessions.
  12.  *
  13.  * @author Daniel Barsotti <daniel.barsotti@liip.ch>
  14.  */
  15. class NodeDumpCommand extends BaseDumpCommand implements ContainerAwareInterface
  16. {
  17.     /**
  18.      * @var ContainerInterface
  19.      */
  20.     private $container;
  21.     /**
  22.      * @var PhpcrConsoleDumperHelper
  23.      */
  24.     private $consoleDumper;
  25.     protected function getContainer()
  26.     {
  27.         if (null === $this->container) {
  28.             $this->container $this->getApplication()->getKernel()->getContainer();
  29.         }
  30.         return $this->container;
  31.     }
  32.     /**
  33.      * {@inheritdoc}
  34.      */
  35.     public function setContainer(ContainerInterface $container null)
  36.     {
  37.         $this->container $container;
  38.     }
  39.     public function setConsoleDumper(PhpcrConsoleDumperHelper $consoleDumper)
  40.     {
  41.         $this->consoleDumper $consoleDumper;
  42.     }
  43.     /**
  44.      * {@inheritdoc}
  45.      */
  46.     protected function configure()
  47.     {
  48.         parent::configure();
  49.         $this
  50.             ->setName('doctrine:phpcr:node:dump')
  51.             ->addOption('session'nullInputOption::VALUE_REQUIRED'The session to use for this command')
  52.         ;
  53.     }
  54.     /**
  55.      * {@inheritdoc}
  56.      */
  57.     protected function execute(InputInterface $inputOutputInterface $output)
  58.     {
  59.         $application $this->getApplication();
  60.         DoctrineCommandHelper::setApplicationPHPCRSession(
  61.             $application,
  62.             $input->getOption('session')
  63.         );
  64.         $helperSet $application->getHelperSet();
  65.         $helperSet->set($this->consoleDumper);
  66.         if (!$input->hasOption('max_line_length')
  67.             && $this->getContainer()->hasParameter('doctrine_phpcr.dump_max_line_length')
  68.         ) {
  69.             $input->setOption('max_line_length'$this->getContainer()->getParameter('doctrine_phpcr.dump_max_line_length'));
  70.         }
  71.         return parent::execute($input$output);
  72.     }
  73. }