Skip to content

Conversation

@tommyseus
Copy link

@tommyseus tommyseus commented May 18, 2017

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-sql

Name: doctrine.entitymanager.some_other
php public/index.php orm:schema-tool:update --dump-sql --entitymanager=some_other

Inspired by the "doctrine/doctrine-mongo-odm-module" --documentmanager option.

@TomHAnderson
Copy link
Member

TomHAnderson commented Jun 1, 2017

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.

@tommyseus
Copy link
Author

Renamed the --entitymanager option to --object-manager option.

Name: doctrine.entitymanager.some_other

php public/index.php orm:schema-tool:update --dump-sql \ --object-manager=doctrine.entitymanager.some_other 
@malarzm
Copy link
Member

malarzm commented Jun 1, 2017

If other maintainers have a view on this I'd like to hear it.

Personally I'd vote for consistency, it's tricky to use entitymanager everywhere except for commands. FWIW em is also used throughout Symfony bundle

@raffykaloustian
Copy link

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.


$arguments = new ArgvInput();
$objectManagerName = $arguments->getParameterOption('--object-manager');
$objectManagerName = !empty($objectManagerName) ? $objectManagerName : 'doctrine.entitymanager.orm_default';
Copy link
Member

@TomHAnderson TomHAnderson Jun 1, 2017

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

$objectManagerName = !empty($objectManagerName) ? $objectManagerName : 'doctrine.entitymanager.orm_default';

/* @var $entityManager \Doctrine\ORM\EntityManagerInterface */
$entityManager = $serviceLocator->get($objectManagerName);
Copy link
Member

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');
Copy link
Member

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());
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

4 participants