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; }
public function generateClass(ClassMetadata $metadata) { $outputDirectory = str_replace($metadata->getBundle()->getNamespace(), "", $metadata->getBundle()->getPath()); $this->writeEntityRepositoryClass($metadata->getRepositoryClass(), $outputDirectory); }
public function displaySummary(GeneratorStyle $io, ClassMetadata $metadata, $fieldName = null) { $headers = ['name', 'type', 'nullable', 'unique']; $rows = []; foreach ($metadata->fieldMappings as $field => $mapping) { if (null !== $fieldName && $fieldName !== $field) { continue; } $row = []; // name $row[] = $field; // type switch ($type = $metadata->getFieldType($field)) { case Type::STRING: $row[] = sprintf('%s(%s)', $type, $metadata->getFieldLength($field)); break; case Type::DECIMAL: $row[] = sprintf('%s (2,0)', $type); break; default: $row[] = $type; break; } // nullable $row[] = $metadata->getFieldNullable($field) ? 'true' : 'false'; // unique $row[] = $metadata->getFieldUnique($field) ? 'true' : 'false'; $rows[] = $row; } $io->table($headers, $rows); }
/** * Asks the name of the field that completes the bidirectional association on the inverse side. * The key 'inversedBy' must be specified on the owning side of a bidirectional association. * * @param InputInterface $input * @param OutputInterface $output * @param ClassMetadata $metadata * @param string $associationName * * @return string */ private function askAssociationInversedBy(GeneratorStyle $io, ClassMetadata $metadata, $associationName = null) { // Get actual field inversedBy based on field name // or default value if not set. $inversedBy = $metadata->getAssociationInversedBy($associationName) ?: static::DEFAULT_INVERSED_BY; // Create new question return $io->ask('Inversed by', $inversedBy, function ($answer) { // return $answer; }); }
public function displayGeneralInformations(GeneratorStyle $io, ClassMetadata $metadata) { $io->table([], [['Name', $metadata->getEntityClassName()], ['Bundle', $metadata->getBundle()->getNamespace()], ['Namespace', $metadata->getName()], ['Repository', $metadata->customRepositoryClassName], ['Entity path', $metadata->getPath()], ['Repository path', $metadata->getRepositoryPath()]]); return $this; }