-
- Notifications
You must be signed in to change notification settings - Fork 226
Added a option to use a different entity-manager on cli #524
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
Added a option to use a different entity-manager on cli #524
Conversation
| I've had this exact problem before and have written my own console tool to solve it. So I'm OK with this functionality addition. However there's some disagreement between developers as to whether we're talking about an Object Manager or Entity Manager. Technically it is an Entity Manager but my view and I believe the common view of Doctrine maintainers is the more generic Object Manager term should be used and we're not going to rename everything even though Entity Manager was a mistake. Therefore for new functionality I won't continue to make the same mistake. Please change your command line parameter to --object-manager=doctrine.entitymanager.orm_other If other maintainers have a view on this I'd like to hear it. Else my terminology will need to be used here. |
| Renamed the --entitymanager option to --object-manager option. Name: doctrine.entitymanager.some_other |
Personally I'd vote for consistency, it's tricky to use |
| I too am an advocate of consistency, however, this is an opportunity to make an adjustment for correctness. Also, I prefer the usage of a fully qualified identifier (e.g. doctrine.entitymanager.some_other) - now that we are not presuming entitymanager. |
src/DoctrineORMModule/Module.php Outdated
| | ||
| $arguments = new ArgvInput(); | ||
| $objectManagerName = $arguments->getParameterOption('--object-manager'); | ||
| $objectManagerName = !empty($objectManagerName) ? $objectManagerName : 'doctrine.entitymanager.orm_default'; |
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.
Please change to
$objectManagerName = ($arguments->getParameterOption('--object-manager')) ?: 'doctrine.entitymanager.orm_default'; This removes re-assigning $objectManagerName
src/DoctrineORMModule/Module.php Outdated
| $objectManagerName = !empty($objectManagerName) ? $objectManagerName : 'doctrine.entitymanager.orm_default'; | ||
| | ||
| /* @var $entityManager \Doctrine\ORM\EntityManagerInterface */ | ||
| $entityManager = $serviceLocator->get($objectManagerName); |
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.
Change $entityManager to $objectManager
| $this->entityManager = $serviceManager->get('doctrine.entitymanager.orm_default'); | ||
| $this->cli = $serviceManager->get('doctrine.cli'); | ||
| $this->serviceManager = $serviceManager; | ||
| $this->entityManager = $serviceManager->get('doctrine.entitymanager.orm_default'); |
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.
Change class property to $this->objectManager
| $this->assertFalse($entityManagerOption->isArray()); | ||
| $this->assertNull($entityManagerOption->getShortcut()); | ||
| $this->assertSame('doctrine.entitymanager.orm_default', $entityManagerOption->getDefault()); | ||
| $this->assertSame('The name of the object-manager to use.', $entityManagerOption->getDescription()); |
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.
object-manager is not hyphenated in sentence context. Please change to object manager
Added a option to use a different entity-manager on cli.
Name: doctrine.entitymanager.orm_default
php public/index.php orm:schema-tool:update --dump-sqlName: doctrine.entitymanager.some_other
php public/index.php orm:schema-tool:update --dump-sql --entitymanager=some_otherInspired by the "doctrine/doctrine-mongo-odm-module" --documentmanager option.