/**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     DoctrineCommandHelper::setApplicationPHPCRSession($this->getApplication(), $input->getOption('session'));
     $session = $this->getHelperSet()->get('phpcr')->getSession();
     $container = $this->getContainer();
     $migrators = $container->getParameter('doctrine_phpcr.migrate.migrators');
     $migratorName = $input->getArgument('migrator_name');
     if (!$migratorName) {
         $output->write('Available migrators:', true);
         $output->write(implode("\n", array_keys($migrators)), true);
         return 0;
     }
     $id = isset($migrators[$migratorName]) ? $migrators[$migratorName] : null;
     if (!$id || !$container->has($id)) {
         throw new \InvalidArgumentException("Wrong value '{$migratorName}' for migrator_name argument.\nAvailable migrators:\n" . implode("\n", array_keys($migrators)));
     }
     $migrator = $container->get($id);
     $migrator->init($session, $output);
     $identifier = $input->getOption('identifier');
     $depth = $input->getOption('depth');
     $output->write("Migrating identifier '{$identifier}' with depth '{$depth}' using '{$migratorName}'", true);
     $exitCode = $migrator->migrate($identifier, $depth);
     if (0 === $exitCode) {
         $output->write('Successful', true);
     } else {
         $output->write('Failed!', true);
     }
     return $exitCode;
 }
Exemplo n.º 2
0
 /**
  * Executes the current command.
  *
  * @param InputInterface  $input  An InputInterface instance
  * @param OutputInterface $output An OutputInterface instance
  *
  * @return integer 0 if everything went fine, or an error code
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     DoctrineCommandHelper::setApplicationPHPCRSession($this->getApplication(), $input->getOption('session'));
     if ($this->getContainer()->hasParameter('doctrine_phpcr.dump_max_line_length')) {
         $this->setDumpMaxLineLength($this->getContainer()->getParameter('doctrine_phpcr.dump_max_line_length'));
     }
     parent::execute($input, $output);
 }
Exemplo n.º 3
0
 /**
  * {@inheritDoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $application = $this->getApplication();
     DoctrineCommandHelper::setApplicationPHPCRSession($application, $input->getOption('session'));
     $helperSet = $application->getHelperSet();
     $helperSet->set($this->getContainer()->get('doctrine_phpcr.console_dumper'));
     if (!$input->getParameterOption('max_line_length') && $this->getContainer()->hasParameter('doctrine_phpcr.dump_max_line_length')) {
         $input->setOption('max_line_length', $this->getContainer()->getParameter('doctrine_phpcr.dump_max_line_length'));
     }
     return parent::execute($input, $output);
 }
 /**
  * @see Command
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $application = $this->getApplication();
     $sessionName = $input->getOption('session');
     if (empty($sessionName)) {
         $container = $application->getKernel()->getContainer();
         $sessionName = $container->getParameter('doctrine_phpcr.default_session');
     }
     DoctrineCommandHelper::setApplicationConnection($application, $sessionName);
     parent::execute($input, $output);
 }
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if ($input->getOption('dm')) {
         $dmName = $input->getOption('dm');
     } elseif ($input->getOption('session')) {
         $dmName = $input->getOption('session');
         trigger_error('The session attribute for command doctrine:phpcr:fixtures:load is deprecated. Use --dm instead.', E_USER_DEPRECATED);
     } else {
         $dmName = null;
     }
     DoctrineCommandHelper::setApplicationDocumentManager($this->getApplication(), $dmName);
     return parent::execute($input, $output);
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if (class_exists('Doctrine\\ODM\\PHPCR\\Tools\\Console\\Command\\RegisterSystemNodeTypesCommand')) {
         DoctrineCommandHelper::setApplicationPHPCRSession($this->getApplication(), $input->getOption('session'));
         $command = new RegisterSystemNodeTypesCommand();
         $command->setApplication($this->getApplication());
         $command->execute($input, $output);
     }
     $initializerManager = $this->getContainer()->get('doctrine_phpcr.initializer_manager');
     $initializerManager->setLoggingClosure(function ($message) use($output) {
         $output->writeln($message);
     });
     $initializerManager->initialize();
 }
Exemplo n.º 7
0
 /**
  * {@inheritDoc}
  */
 public function execute(InputInterface $input, OutputInterface $output)
 {
     $container = $this->getContainer();
     $manager = $container->get('doctrine_phpcr');
     $factory = $container->get('cmf_routing_auto.metadata.factory');
     $arm = $container->get('cmf_routing_auto.auto_route_manager');
     $dm = $manager->getManager();
     $uow = $dm->getUnitOfWork();
     $session = $input->getOption('session');
     $dryRun = $input->getOption('dry-run');
     $class = $input->getOption('class');
     $verbose = $input->getOption('verbose');
     DoctrineCommandHelper::setApplicationPHPCRSession($this->getApplication(), $session);
     if ($class) {
         $mapping = array($class => $class);
     } else {
         $mapping = iterator_to_array($factory->getIterator());
     }
     foreach (array_keys($mapping) as $classFqn) {
         $output->writeln(sprintf('<info>Processing class: </info> %s', $classFqn));
         $qb = $dm->createQueryBuilder();
         $qb->from()->document($classFqn, 'a');
         $q = $qb->getQuery();
         $result = $q->getResult();
         foreach ($result as $autoRouteableDocument) {
             $id = $uow->getDocumentId($autoRouteableDocument);
             $output->writeln('  <info>Refreshing: </info>' . $id);
             $uriContextCollection = new UriContextCollection($autoRouteableDocument);
             $arm->buildUriContextCollection($uriContextCollection);
             foreach ($uriContextCollection->getUriContexts() as $uriContext) {
                 $autoRoute = $uriContext->getAutoRoute();
                 $dm->persist($autoRoute);
                 $autoRouteId = $uow->getDocumentId($autoRoute);
                 if ($verbose) {
                     $output->writeln(sprintf('<comment>    - %sPersisting: </comment> %s <comment>%s</comment>', $dryRun ? '(dry run) ' : '', $autoRouteId, '[...]' . substr(get_class($autoRoute), -10)));
                 }
                 if (true !== $dryRun) {
                     $dm->flush();
                 }
             }
         }
     }
 }
Exemplo n.º 8
0
 /**
  * {@inheritDoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if (!class_exists('PHPCR\\Shell\\Console\\Application\\SessionApplication')) {
         throw new \InvalidArgumentException(sprintf('PHPCR-Shell not installed as a dependency. Add the "phpcr/phpcr-shell" to your ' . 'composer.json file to use this command'));
     }
     DoctrineCommandHelper::setApplicationPHPCRSession($this->getApplication(), $input->getOption('session'));
     $args = $input->getArgument('cmd');
     $launchShell = empty($args);
     $session = $this->getHelper('phpcr')->getSession();
     // If no arguments supplied, launch the shell uwith the embedded application
     if ($launchShell) {
         $shell = PhpcrShell::createEmbeddedShell($session);
         $exitCode = $shell->run();
         return $exitCode;
     }
     // else try and run the command using the given input
     $application = PhpcrShell::createEmbeddedApplication($session);
     $exitCode = $application->runWithStringInput(implode(' ', $args), $output);
     // always save the session after running a single command
     $session->save();
     return $exitCode;
 }
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     DoctrineCommandHelper::setApplicationPHPCRSession($this->getApplication(), $input->getOption('session'), true);
     $definitions = $input->getArgument('cnd-file');
     $application = $this->getApplication();
     // if no cnd-files, automatically load from bundles
     if (0 === count($definitions)) {
         $bundles = $application->getKernel()->getBundles();
         $candidatePaths = array();
         foreach ($bundles as $bundle) {
             $candidatePath = sprintf('%s/%s', $bundle->getPath(), self::BUNDLE_NT_PATH);
             if (!file_exists($candidatePath)) {
                 continue;
             }
             $candidatePaths[] = $candidatePath;
         }
         if (0 === count($candidatePaths)) {
             $output->writeln(sprintf('No definition files specified and could not find any definitions in any <comment><bundle>/%s</comment> folders. Aborting.', self::BUNDLE_NT_PATH));
             return 1;
         }
         $input->setArgument('cnd-file', $candidatePaths);
     }
     return parent::execute($input, $output);
 }
Exemplo n.º 10
0
 /**
  * {@inheritDoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     DoctrineCommandHelper::setApplicationPHPCRSession($this->getApplication(), $input->getOption('session'));
     return parent::execute($input, $output);
 }
Exemplo n.º 11
0
 /**
  * {@inheritDoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if ($input->getOption('name')) {
         trigger_error('The name attribute for command doctrine:phpcr:fixtures:load is deprecated. It was never used.', E_USER_DEPRECATED);
     }
     if ($input->getOption('dm')) {
         $dmName = $input->getOption('dm');
     } else {
         if ($input->getOption('session')) {
             $dmName = $input->getOption('session');
             trigger_error('The session attribute for command doctrine:phpcr:fixtures:load is deprecated. Use --dm instead.', E_USER_DEPRECATED);
         } else {
             $dmName = null;
         }
     }
     DoctrineCommandHelper::setApplicationDocumentManager($this->getApplication(), $dmName);
     $dm = $this->getHelperSet()->get('phpcr')->getDocumentManager();
     $noInitialize = $input->getOption('no-initialize');
     if ($input->isInteractive() && !$input->getOption('append')) {
         /** @var $dialog DialogHelper */
         $dialog = $this->getHelperSet()->get('dialog');
         if (!$dialog->askConfirmation($output, '<question>Careful, database will be purged. Do you want to continue Y/N ?</question>', false)) {
             return 0;
         }
     }
     $dirOrFile = $input->getOption('fixtures');
     if ($dirOrFile) {
         $paths = is_array($dirOrFile) ? $dirOrFile : array($dirOrFile);
     } else {
         $paths = array();
         foreach ($this->getApplication()->getKernel()->getBundles() as $bundle) {
             $paths[] = $bundle->getPath() . '/DataFixtures/PHPCR';
         }
     }
     $loader = new ContainerAwareLoader($this->getContainer());
     foreach ($paths as $path) {
         if (is_dir($path)) {
             $loader->loadFromDirectory($path);
         }
     }
     $fixtures = $loader->getFixtures();
     if (!$fixtures) {
         throw new InvalidArgumentException(sprintf('Could not find any fixtures to load in: %s', "\n\n- " . implode("\n- ", $paths)));
     }
     $purger = new PHPCRPurger($dm);
     if ($noInitialize) {
         $initializerManager = null;
     } else {
         $initializerManager = $this->getContainer()->get('doctrine_phpcr.initializer_manager');
     }
     $executor = new PHPCRExecutor($dm, $purger, $initializerManager);
     $executor->setLogger(function ($message) use($output) {
         $output->writeln(sprintf('  <comment>></comment> <info>%s</info>', $message));
     });
     $executor->execute($fixtures, $input->getOption('append'));
     return 0;
 }
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     DoctrineCommandHelper::setApplicationDocumentManager($this->getApplication(), $input->getOption('session'));
     parent::execute($input, $output);
 }