本文整理汇总了PHP中Doctrine\ORM\Tools\EntityGenerator::setBackupExisting方法的典型用法代码示例。如果您正苦于以下问题:PHP EntityGenerator::setBackupExisting方法的具体用法?PHP EntityGenerator::setBackupExisting怎么用?PHP EntityGenerator::setBackupExisting使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\ORM\Tools\EntityGenerator
的用法示例。
在下文中一共展示了EntityGenerator::setBackupExisting方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: initGenerator
protected function initGenerator()
{
$this->generator->setGenerateAnnotations(true);
$this->generator->setBackupExisting(false);
$this->generator->setGenerateStubMethods(true);
$this->generator->setRegenerateEntityIfExists(true);
$this->generator->setUpdateEntityIfExists(false);
if ($this->parentClassName != null) {
$this->generator->setClassToExtend($this->parentClassName);
}
return $this->generator;
}
示例2: testRegenerateEntityClass
public function testRegenerateEntityClass()
{
$metadata = $this->generateBookEntityFixture();
$this->loadEntityClass($metadata);
$className = basename(str_replace('\\', '/', $metadata->name));
$path = $this->_tmpDir . '/' . $this->_namespace . '/' . $className . '.php';
$classTest = file_get_contents($path);
$this->_generator->setRegenerateEntityIfExists(true);
$this->_generator->setBackupExisting(false);
$this->_generator->writeEntityClass($metadata, $this->_tmpDir);
$classNew = file_get_contents($path);
$this->assertSame($classTest, $classNew);
}
示例3: fire
public function fire()
{
$this->info('Starting entities generation....');
// flush all generated and cached entities, etc
\D2Cache::flushAll();
$cmf = new DisconnectedClassMetadataFactory();
$cmf->setEntityManager($this->d2em);
$metadata = $cmf->getAllMetadata();
if (empty($metadata)) {
$this->error('No metadata found to generate entities.');
return -1;
}
$directory = Config::get('d2doctrine.paths.entities');
if (!$directory) {
$this->error('The entity directory has not been set.');
return -1;
}
$entityGenerator = new EntityGenerator();
$entityGenerator->setGenerateAnnotations($this->option('generate-annotations'));
$entityGenerator->setGenerateStubMethods($this->option('generate-methods'));
$entityGenerator->setRegenerateEntityIfExists($this->option('regenerate-entities'));
$entityGenerator->setUpdateEntityIfExists($this->option('update-entities'));
$entityGenerator->setNumSpaces($this->option('num-spaces'));
$entityGenerator->setBackupExisting(!$this->option('no-backup'));
$this->info('Processing entities:');
foreach ($metadata as $item) {
$this->line($item->name);
}
try {
$entityGenerator->generate($metadata, $directory);
$this->info('Entities have been created.');
} catch (\ErrorException $e) {
if ($this->option('verbose') == 3) {
throw $e;
}
$this->error("Caught ErrorException: " . $e->getMessage());
$this->info("Re-optimizing:");
$this->call('optimize');
$this->comment("*** You must now rerun this artisan command ***");
exit(-1);
}
}
示例4: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$em = $this->getHelper('em')->getEntityManager();
$cmf = new DisconnectedClassMetadataFactory();
$cmf->setEntityManager($em);
$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("Entities destination directory '<info>%s</info>' does not exist.", $input->getArgument('dest-path')));
}
if (!is_writable($destPath)) {
throw new \InvalidArgumentException(sprintf("Entities destination directory '<info>%s</info>' does not have write permissions.", $destPath));
}
if (count($metadatas)) {
// Create EntityGenerator
$entityGenerator = new EntityGenerator();
$entityGenerator->setGenerateAnnotations($input->getOption('generate-annotations'));
$entityGenerator->setGenerateStubMethods($input->getOption('generate-methods'));
$entityGenerator->setRegenerateEntityIfExists($input->getOption('regenerate-entities'));
$entityGenerator->setUpdateEntityIfExists($input->getOption('update-entities'));
$entityGenerator->setNumSpaces($input->getOption('num-spaces'));
$entityGenerator->setBackupExisting(!$input->getOption('no-backup'));
if (($extend = $input->getOption('extend')) !== null) {
$entityGenerator->setClassToExtend($extend);
}
foreach ($metadatas as $metadata) {
$output->writeln(sprintf('Processing entity "<info>%s</info>"', $metadata->name));
}
// Generating Entities
$entityGenerator->generate($metadatas, $destPath);
// Outputting information message
$output->writeln(PHP_EOL . sprintf('Entity classes generated to "<info>%s</INFO>"', $destPath));
} else {
$output->writeln('No Metadata Classes to process.');
}
}
示例5: getEntityGenerator
protected function getEntityGenerator()
{
$entityGenerator = new EntityGenerator();
$entityGenerator->setGenerateStubMethods(true);
$entityGenerator->setRegenerateEntityIfExists(true);
$entityGenerator->setBackupExisting(true);
return $entityGenerator;
}
示例6: generateEntities
/**
* Generate entity classes
*
* @param array $metadata
*/
protected function generateEntities(array $metadata)
{
$generator = new EntityGenerator();
$generator->setGenerateAnnotations(true);
$generator->setGenerateStubMethods(true);
$generator->setRegenerateEntityIfExists(false);
$generator->setUpdateEntityIfExists(true);
$generator->setBackupExisting(false);
if (null !== ($superclass = $this->getSuperclass())) {
$generator->setClassToExtend($superclass);
}
/* @var $classMetadata \Doctrine\ORM\Mapping\ClassMetadata */
foreach ($metadata as $classMetadata) {
$className = end(explode('\\', $classMetadata->getName()));
$classMetadata->setCustomRepositoryClass($this->getNsRepository() . $className);
if (null !== ($prefix = $this->getSequencePrefix())) {
$classMetadata->setSequenceGeneratorDefinition(array('sequenceName' => strtoupper($prefix . '_' . $className)));
}
}
$generator->generate($metadata, $this->getDirectory());
}