setUpdateDocumentIfExists() public méthode

Set whether or not to try and update the document if it already exists
public setUpdateDocumentIfExists ( boolean $bool ) : void
$bool boolean
Résultat void
 /**
  * @return \Doctrine\ODM\MongoDB\Tools\DocumentGenerator
  */
 protected function getDocumentGenerator()
 {
     $documentGenerator = new DocumentGenerator();
     $documentGenerator->setGenerateAnnotations(true);
     $documentGenerator->setGenerateStubMethods(true);
     $documentGenerator->setRegenerateDocumentIfExists(false);
     $documentGenerator->setUpdateDocumentIfExists(true);
     $documentGenerator->setNumSpaces(4);
     return $documentGenerator;
 }
 /**
  * @see Console\Command\Command
  */
 protected function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
 {
     $dm = $this->getHelper('documentManager')->getDocumentManager();
     $cmf = new DisconnectedClassMetadataFactory();
     $cmf->setDocumentManager($dm);
     $cmf->setConfiguration($dm->getConfiguration());
     $metadatas = $cmf->getAllMetadata();
     $metadatas = MetadataFilter::filter($metadatas, $input->getOption('filter'));
     // Process destination directory
     $destPath = realpath($input->getArgument('dest-path'));
     if (!file_exists($destPath)) {
         throw new \InvalidArgumentException(sprintf("Documents destination directory '<info>%s</info>' does not exist.", $destPath));
     } elseif (!is_writable($destPath)) {
         throw new \InvalidArgumentException(sprintf("Documents destination directory '<info>%s</info>' does not have write permissions.", $destPath));
     }
     if (count($metadatas)) {
         // Create DocumentGenerator
         $documentGenerator = new DocumentGenerator();
         $documentGenerator->setGenerateAnnotations($input->getOption('generate-annotations'));
         $documentGenerator->setGenerateStubMethods($input->getOption('generate-methods'));
         $documentGenerator->setRegenerateDocumentIfExists($input->getOption('regenerate-documents'));
         $documentGenerator->setUpdateDocumentIfExists($input->getOption('update-documents'));
         $documentGenerator->setBackupExisting(!$input->getOption('no-backup'));
         $documentGenerator->setNumSpaces($input->getOption('num-spaces'));
         if (($extend = $input->getOption('extend')) !== null) {
             $documentGenerator->setClassToExtend($extend);
         }
         foreach ($metadatas as $metadata) {
             $output->writeln(sprintf('Processing document "<info>%s</info>".', $metadata->name));
         }
         // Generating Documents
         $documentGenerator->generate($metadatas, $destPath);
         // Outputting information message
         $output->writeln(array('', sprintf('Document classes have been generated to "<info>%s</info>".', $destPath)));
     } else {
         $output->writeln('No Metadata Classes to process.');
     }
 }