Skip to content
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

Fix for alternate entity managers in cli (Issue #58). #75

Closed
wants to merge 1 commit into from

Conversation

brettalewis
Copy link

I didn't realize I couldn't easily connect these, so I'm referencing the issue here.

@Ocramius
Copy link
Member

Can you check this on all commands with travis? see .travis/run-cli.sh and add a set of tests for a new EntityManager (add it to .travis/travis.local.php). To enable travis, go to http://travis-ci.org/

@@ -90,10 +93,20 @@ public function onBootstrap(EventInterface $e)
new VersionCommand(),
));

$allCommands = $cli->all('orm');
foreach($allCommands as $cmd) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I like the solution, plus we need a more unique parameter instead of --em. Please add the tests if possible

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was also torn on this solution, but the alternative was to write a HelperSet for the ServiceManager and add wrappers for all commands. The wrappers would extend off of an abstract class that would read the InputStream, take the ServiceManager and pull the appropriate EntityManager and Connection.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a single wrapper could work if you override the configure method and proxy all other calls to the wrapped command...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something like

<?php
class MyCommandWrapper implements Command
{
    public function __construct(Command $command, ServiceLocatorInterface $sl) {}
    public function configure()
    {
        $this->command->configure();
        $this->addOption(...);
    }
    // proxy remaining methods
}

@Ocramius
Copy link
Member

@brettalewis ping

@Ocramius
Copy link
Member

(also, a rebase is needed)

@Ocramius Ocramius closed this Aug 1, 2012
/* @var $sm ServiceLocatorInterface */
$sm = $e->getParam('ServiceManager');
/* @var $em \Doctrine\ORM\EntityManager */
$em = $sm->get('doctrine.entitymanager.orm_default');
$em = $sm->get('doctrine.entitymanager.' . $emName);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also here, wouldn't enforce any prefix.

@Ocramius
Copy link
Member

Ocramius commented Aug 1, 2012

Opened #97 instead

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

Successfully merging this pull request may close these issues.

None yet

2 participants