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

Improvement to IDE-friendliness when 'wrapper_class' option is used #663

Closed
wants to merge 4 commits into from

Conversation

Xymanek
Copy link
Contributor

@Xymanek Xymanek commented May 25, 2017

Sets the class property in service definition to assist IDEs in knowing what class the service really is. Since connection services use a factory, the class option doesn't affect anything. I've tested the logic with following "hack" and it works without any problems:

class DataConnectionCompilerPass implements CompilerPassInterface
{
    public function process (ContainerBuilder $container)
    {
        $service = $container->findDefinition('doctrine.dbal.data_connection');
        $service->setClass(DataConnectionWrapper::class);
    }
}

P.S. Why so many privates in \Doctrine\DBAL\Connection? Makes extending it so hard....

);

$this->assertEquals(TestWrapperClass::class, $container->getDefinition('doctrine.dbal.default_connection')->getClass());
$this->assertEquals(null, $container->getDefinition('doctrine.dbal.second_connection')->getClass());
Copy link
Contributor

Choose a reason for hiding this comment

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

assertNull()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ooops

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Anything else? Don't want to pollute with commits

@Ocramius
Copy link
Member

P.S. Why so many privates in \Doctrine\DBAL\Connection? Makes extending it so hard....

It's not meant to be extended.

@Xymanek
Copy link
Contributor Author

Xymanek commented May 30, 2017

Anything else needs to be done?

Copy link
Contributor

@weaverryan weaverryan left a comment

Choose a reason for hiding this comment

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

@Xymanek Can you resolve the conflict?

// Set class in case "wrapper_class" option was used to assist IDEs
if (isset($options['wrapperClass'])) {
$def->setClass($options['wrapperClass']);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I would move this up to after line 211 - so right after $def =

@weaverryan
Copy link
Contributor

+1 The wrapperClass option is ultimately used in the DBAL to create a class of that specific instance. So, yea, technically, the definition's should match the actual class that will be created.

@Xymanek
Copy link
Contributor Author

Xymanek commented Jun 3, 2017

@weaverryan Fixed and fixed

@Ocramius
Copy link
Member

Ocramius commented Jun 3, 2017

@Xymanek can you please rebase instead of merging master? Commit Xymanek/DoctrineBundle@1245734 should go away

@Xymanek
Copy link
Contributor Author

Xymanek commented Jun 6, 2017

@Ocramius can you please give me a hint on how to do that? I kinda know what you mean but not sure how to do it cross-repository...

@Ocramius
Copy link
Member

Ocramius commented Jun 6, 2017

@Xymanek I'll do that now while merging :-)

If you never did it before, consider reading https://www.atlassian.com/git/tutorials/rewriting-history

@Ocramius Ocramius self-assigned this Jun 6, 2017
@Ocramius Ocramius modified the milestones: 1.7.1, 1.8.0 Jun 6, 2017
@Ocramius Ocramius closed this in 1818d3d Jun 6, 2017
@Ocramius
Copy link
Member

Ocramius commented Jun 6, 2017

Manually rebased and merged via 1818d3d

Thanks @Xymanek!

@kimhemsoe kimhemsoe removed this from the 1.8.0 milestone Aug 25, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants