-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
provide a compiler pass for doctrine to register namespace aliases #10853
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
Conversation
* 'doctrine.orm.%s_metadata_driver' | ||
* @var string | ||
*/ | ||
protected $driverPattern; |
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 is a micro BC break as in the base class i call this serviceNamePattern
and its only protected. we could either use a wrong name in the base class or keep this field (but then instead of a php error we would get a semantic error if the value is directly read / assigned.)
as none of the doctrine bundles directly accesses the value, i think the BC break would hit only people that did a custom extension of this pass, which i doubt exists.
i think the test failure is not related to what i did. |
Nope, it's not you, take a look #10826, all test failed from 5.5 |
looks good to me |
I would indeed deprecate the current one and create just one pass to switch to. |
had a go at cleaning this up and realized that we can keep BC and just add more constructor arguments. this will be a lot more convenient for consumers - they can just pass additional parameters that are ignored on older symfony versions and don't get namespace alias but do get the rest. |
* is used, the others skipped. | ||
* | ||
* The $alias parameter can be used to define bundle namespace shortcuts as the DoctrineBundle | ||
* provides automatically for objects in the default Entity/Document folder. |
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 found no explicit documentation to link to, but alias are mentioned in this section of the book http://symfony.com/doc/current/book/doctrine.html#fetching-objects-from-the-database
Once we agree on this, i will update https://github.com/symfony/symfony-docs/blob/master/cookbook/doctrine/mapping_model_classes.rst and update the orm and mongo, couch bundles. phpcr-odm is being updated already: doctrine/DoctrinePHPCRBundle#158 |
$enabledParameter = false, | ||
$configurationPattern = '', | ||
$registerAliasMethodName = '', | ||
array $alias = array() |
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.
As mentioned in https://github.com/doctrine/DoctrinePHPCRBundle/pull/158/files#r15399221 maybe this should be $aliasMap
or $aliases
?
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.
fixed to aliasMap, thanks
@fabpot what do you think about this? ok like this? the parameter order in the constructor is not awesome, but is BC compatible, simplifying the live of doctrine bundles that build on top of this a lot. |
Looks good to me. |
did pull requests for the orm and phpcr-odm bundles, and the symfony-docs (links in issue description). how do we proceed? @beberlei can you give some feedback on the doctrine bundle PR? |
$chainDriverDefService = $this->getChainDriverServiceName($container); | ||
$chainDriverDef = $container->getDefinition($chainDriverDefService); | ||
foreach ($this->namespaces as $namespace) { | ||
// instance of Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain |
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.
If you have to commit again you could change that to /** @var \Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain $chainDriverDef */
and move it up.
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.
of course. must have been tired. thanks for spotting, fixed.
* Map of alias to namespace. | ||
* @var array | ||
*/ | ||
protected $aliasMap; |
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.
should we use private properties instead ?
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 are a couple of existing properties already, we can't restrict them as it would be a BC break. but can make these private, would have been better.
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 know we canot change the existing ones. I'm talking about the new ones here
This also needs to be rebased to fix conflicts |
thanks for the feedback stof, agreeing and updated all points you noted. no idea where that conflict came from. but i rebased on upstream/master and seems good now. |
* @throws ParameterNotFoundException if none of the managerParameters has a | ||
* non-empty value. | ||
* | ||
* @since 2.6 |
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.
It's private
so I would say that it can be removed.
We are ready to merge doctrine/DoctrineBundle#316 whenever you are. We have a DoctrineBundle 1.3 release, that we are planning to do this week. Do you want us to post prone until this PR gets merged? |
@dbu Do you have time to finish this PR so that it can be merged fast? |
…d not only mapping drivers
adjusted to the feedback of @stloyd would be great if this can make it into DoctrineBundle 1.3. @kimhemsoe there is no problem merging the DoctrineBundle PR for older symfony versions, as its just extra parameters to the constructor that php will ignore. |
What is the status of this ? I know it it will not break anything, but we rather wait on this PR to merge before merging DoctrineBundle one. |
👍 |
@kimhemsoe here we wait for input from the doctrine orm maintainers :-) beberlei said that @kimhemsoe is release manager of the doctrine bundle. so i think the comment above is an approval from doctrine and we can merge this, right? |
👍 |
1 similar comment
👍 |
Thank you @dbu. |
…pace aliases (dbu) This PR was merged into the 2.6-dev branch. Discussion ---------- provide a compiler pass for doctrine to register namespace aliases | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | yes | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | symfony/symfony-docs#4069 I realized that the compiler pass only allows bundles to register folders to load entities / documents but not namespace alias to make things like `CmfRoutingBundle:Route` work. This is an attempt to provide a separate compiler pass for this. Maybe we should instead provide a new combined compiler pass and have users switch to the new pass if available. * [x] [Doctrine ORM](doctrine/DoctrineBundle#316) * [x] [DoctrinePHPCRBundle](doctrine/DoctrinePHPCRBundle#158) * [ ] Doctrine CouchDB * [ ] Doctrine MongoDB Commits ------- 9a62ab3 provide a compiler pass for doctrine to register namespace aliases and not only mapping drivers
This PR was merged into the master branch. Discussion ---------- document the namespace alias feature | Q | A | ------------- | --- | Doc fix? | no | New docs? | [yes](symfony/symfony#10853) | Applies to | 2.6 | Fixed tickets | - Commits ------- d753d0e document the namespace alias feature
I realized that the compiler pass only allows bundles to register folders to load entities / documents but not namespace alias to make things like
CmfRoutingBundle:Route
work. This is an attempt to provide a separate compiler pass for this. Maybe we should instead provide a new combined compiler pass and have users switch to the new pass if available.