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
 /**
  * Asks field mappings informations.
  *
  * @param GeneratorStyle $io
  * @param ClassMetadata $metadata
  *
  * @return array
  */
 public function askFieldMappings(GeneratorStyle $io, ClassMetadata $metadata)
 {
     // Display step description
     $io->section('Field definitions');
     // Ask all already mapped fields for edition
     foreach ($metadata->fieldMappings as $fieldName => $mapping) {
         // Do not edit id field
         if ($fieldName === 'id') {
             continue;
         }
         $mapping = $this->askFieldMapping($io, $metadata, $fieldName);
         $metadata->overrideField($fieldName, $mapping);
     }
     if (count($metadata->fieldMappings) <= 1) {
         $io->text('Instead of starting with a blank entity, you can add some fields now.');
         $io->text('Note that the primary key will be added automatically (named <comment>id</comment>).');
     }
     // Recursively ask new field mappings
     while (null !== ($mapping = $this->askFieldMapping($io, $metadata))) {
         // Map field to metadata
         $metadata->mapField($mapping);
     }
     return $this;
 }
예제 #4
0
 /**
  * Displays entity summary.
  *
  * @param OutputInterface   $output
  * @param ClassMetadata $metadata
  *
  * @return MetadataHelper
  */
 public function displaySummary(GeneratorStyle $io, ClassMetadata $metadata)
 {
     $io->section('Entity summary');
     $io->comment('General informations');
     $this->displayGeneralInformations($io, $metadata);
     $io->comment(sprintf('%s field mapping(s)', count($metadata->fieldMappings)));
     $this->fieldHelper->displaySummary($io, $metadata);
     return $this;
 }