-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Add JSON format option for orm:mapping:describe command output #12071
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 3.6.x
Are you sure you want to change the base?
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
dc3fb09
to
021c815
Compare
I've just updated the command help / description + added autocomplete for --format option (with text as default ) |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
021c815
to
f68b1d3
Compare
@@ -55,6 +56,7 @@ protected function configure(): void | |||
->addArgument('entityName', InputArgument::REQUIRED, 'Full or partial name of entity') | |||
->setDescription('Display information about mapped objects') | |||
->addOption('em', null, InputOption::VALUE_REQUIRED, 'Name of the entity manager to operate on') | |||
->addOption('format', null, InputOption::VALUE_REQUIRED, 'Output format (json, text)', 'text') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There seems to be an indention problem here.
->addOption('format', null, InputOption::VALUE_REQUIRED, 'Output format (json, text)', 'text') | |
->addOption('format', null, InputOption::VALUE_REQUIRED, 'Output format (json, text)', 'text') |
@@ -72,7 +83,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int | |||
|
|||
$entityManager = $this->getEntityManager($input); | |||
|
|||
$this->displayEntity($input->getArgument('entityName'), $entityManager, $ui); | |||
$this->displayEntity($input->getArgument('entityName'), $entityManager, $ui, $input->getOption('format')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think $input->getOption('format')
should be parsed into an enum representing the possible formats, or at least validated against getAvailableFormatOptions
@@ -100,9 +115,47 @@ private function displayEntity( | |||
string $entityName, | |||
EntityManagerInterface $entityManager, | |||
SymfonyStyle $ui, | |||
string|null $format, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is null
really necessary? Or could text
be the default?
|
||
To use a specific entity manager (e.g., for multi-DB projects), use the <info>--em</info> option: | ||
|
||
<info>%command.full_name% My\Namespace\Entity\MyEntity --em=my_custom_entity_manager</info> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should go in a separate commit.
@@ -115,7 +168,7 @@ private function displayEntity( | |||
$this->formatField('Embedded class?', $metadata->isEmbeddedClass), | |||
$this->formatField('Parent classes', $metadata->parentClasses), | |||
$this->formatField('Sub classes', $metadata->subClasses), | |||
$this->formatField('Embedded classes', $metadata->subClasses), | |||
$this->formatField('Embedded classes', $metadata->embeddedClasses), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should go to a separate commit. If it's a bugfix, it should even go to a separate branch (maybe even a 2.x branch)
Following suggestion from doctrine/DoctrineBundle#1883, this PR adds the
--format=json
option to theorm:mapping:describe
command to enable JSON output (hence allowing jq filtering of said-output).For example, when running
symfony console doctrine:mapping:describe App\\Entity\\Book --format=json
, we get the following output :which we can then filter using jq - for example :
will output a simple fieldMapping + typehint list

Bonus small fix of embeddedClasses output which falsely returned subClasses