public function generateRepository(GeneratorStyle $io, ClassMetadata $metadata)
 {
     /* Repository */
     $io->section('Repository generation');
     $io->text(sprintf('Target path: %s', $metadata->getRepositoryPath()));
     // Generate repository class file
     $this->repositoryGenerator->generateClass($metadata);
     $io->success('Entity repository generated successfully!');
     return $this;
 }
 /**
  * Asks association mappings informations.
  *
  * @param InputInterface    $input
  * @param OutputInterface   $output
  * @param ClassMetadata $metadata
  *
  * @return array
  */
 public function askAssociationMappings(GeneratorStyle $io, ClassMetadata $metadata)
 {
     // Display step description
     $io->section('Association definitions');
     $io->text('You can add some associations now.');
     // Ask all already mapped associations for edition
     foreach ($metadata->associationMappings as $associationName => $mapping) {
         $mapping = $this->askAssociationMapping($associationName);
         $metadata->overrideAssociation($mapping);
     }
     // Recursively ask new association mappings
     while (null !== ($mapping = $this->askAssociationMapping($io, $metadata))) {
         // Map association to metadata
         $metadata->mapAssociation($mapping);
     }
     return $this;
 }
예제 #3
0
 /**
  * Updates the database schema
  * by running the 'doctrine:schema:update' command.
  *
  * @param InputInterface  $input
  * @param OutputInterface $output
  */
 public function runSchemaUpdate(InputInterface $input, OutputInterface $output)
 {
     // Dont update the schema if the option "no-schema-update" is provided.
     if ($input->getOption('no-schema-update')) {
         return;
     }
     $io = new GeneratorStyle($input, $output);
     $io->title('Database schema update');
     $io->text('Updating database schema..');
     // Get the doctrine schema update command.
     $command = $this->getApplication()->find('doctrine:schema:update');
     // Dont run the command if the command is not found.
     if (!$command) {
         $output->writeln('<error>Unable to update the database schema (command not found).</error>');
         return;
     }
     // Create new command input arguments.
     $commandInput = new ArrayInput(['command' => 'doctrine:schema:update', '--force' => true, '--quiet' => true]);
     // Execute the command.
     $command->run($commandInput, $output);
 }