コード例 #1
0
 /**
  * {@inheritDoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     // we do not want to expose the parent options, but use the arguments and
     // options to pass information to the parent.
     parent::configure();
     $classname = $input->getArgument('classname');
     $newClassname = $input->getArgument('new-classname');
     if (!class_exists($newClassname)) {
         throw new \Exception(sprintf('New class name "%s" does not exist.', $newClassname));
     }
     /** @var $documentManager DocumentManager */
     $documentManager = $this->getHelper('phpcr')->getDocumentManager();
     $mapper = $documentManager->getConfiguration()->getDocumentClassMapper();
     $input->setOption('query', sprintf('SELECT * FROM [nt:base] WHERE [phpcr:class] = "%s"', $classname));
     $input->setOption('apply-closure', array(function ($session, $node) use($newClassname, $documentManager, $mapper) {
         $mapper->writeMetadata($documentManager, $node, $newClassname);
     }));
     return parent::execute($input, $output);
 }
コード例 #2
0
 /**
  * {@inheritDoc}
  */
 protected function configure()
 {
     parent::configure();
     $this->setName('doctrine:phpcr:nodes:update')->addOption('session', null, InputOption::VALUE_OPTIONAL, 'The session to use for this command');
 }