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.     public function setContainer(ContainerInterface $container null)
  33.     {
  34.         $this->container $container;
  35.     }
  36.     public function setConsoleDumper(PhpcrConsoleDumperHelper $consoleDumper)
  37.     {
  38.         $this->consoleDumper $consoleDumper;
  39.     }
  40.     /**
  41.      * @return void
  42.      */
  43.     protected function configure()
  44.     {
  45.         parent::configure();
  46.         $this
  47.             ->setName('doctrine:phpcr:node:dump')
  48.             ->addOption('session'nullInputOption::VALUE_REQUIRED'The session to use for this command')
  49.         ;
  50.     }
  51.     /**
  52.      * @return int
  53.      */
  54.     protected function execute(InputInterface $inputOutputInterface $output)
  55.     {
  56.         $application $this->getApplication();
  57.         DoctrineCommandHelper::setApplicationPHPCRSession(
  58.             $application,
  59.             $input->getOption('session')
  60.         );
  61.         $helperSet $application->getHelperSet();
  62.         $helperSet->set($this->consoleDumper);
  63.         if (!$input->hasOption('max_line_length')
  64.             && $this->getContainer()->hasParameter('doctrine_phpcr.dump_max_line_length')
  65.         ) {
  66.             $input->setOption('max_line_length'$this->getContainer()->getParameter('doctrine_phpcr.dump_max_line_length'));
  67.         }
  68.         return parent::execute($input$output);
  69.     }
  70. }