Ok, if auto-detection isn't the must we really should move to the
suggested scheme. :-)
But you are right, Entities outside the bundle scheme are still an issue.
One could register them in the Bundle Extension by accessing the Definition
for 'doctrine.orm.metadata_driver' but that is rather technical.
Mapping Drivers essentially need three pieces of information.
1. Type of the Driver (XML, Annotation, Yaml, PHP, StaticPHP or a service
name)
2. Location of either the mapping data or the entities (depending on the
type of driver)
3. Class-Prefix to attach this driver to for the DriverChain.
We could add another config key for this:
doctrine.orm:
default:
bundles:
...
mappings:
arbitrary_key: { type: xml, dir:
src/vendor/DoctrineExtensions/lib/DoctrineExtensions/Entities, prefix:
DoctrineExtensions\Entities\ }
It would be possible to merge bundles and mappings and detect a bundle by
the key. This is rather magical though. I lean for supporting both key
"bundles" and "mappings". The bundles key is really easy to use and the
mappings key always requires the three options "type", "dir", "prefix". And
by default users really only need the bundles key.
greetings,
Benjamin
On Thu, 09 Dec 2010 09:28:09 +0100, Fabien Potencier
<[email protected]> wrote:
> Hi Benjamin,
>
> First of all, thank you very much for your work on this tough issue.
>
> On 12/8/10 11:21 PM, Benjamin Eberlei wrote:
>> Hello everyone,
>>
>> We discussed the Mapping configuration of the Doctrine bundles in our
>> last IRC meeting and I had the time to investigate possible changes
>> tonight. @Fabien: I know you want the autodetection in to simplify
usage
>> for starters, but there are very real drawbacks about it. I present the
>> problems and a very good solution (that will not even complicate usage
>> for starters).
>
> I don't really "want" auto-detection. I just want something simple for
> newcomers: "Be as simple as possible for newcomers, but as flexible as
> possible for advanced users". Right now, we are probably 'too' simple
> for newcomers and very inflexible for advanced users.
>
>> Solution:
>>
>> 1. Be explicit! At the minimum you have to configure which bundle uses
>> which ORM/ODM. See a cascading example of the possible configuration
>> complexities:
>>
>> doctrine.orm:
>> default:
>> bundles:
>> bundleName1: ~
>> bundleName2: yml
>> bundleName3: { type: annotation, dir: Entities/ }
>> bundleName4: { type: xml, dir:
>> Resources/config/doctrine/mapping }
>> bundleName5: { type: yml, dir: doctrine/metadata }
>> bundleName6:
>> type: yml
>> dir: [bundle-mappings1/, bundle-mappings2/]
>> bundleName7:
>> type: my-driver-service
>
> That's very similar to how the routing configuration works. Routes from
> bundles are never automatically registered. You need to explicitly
> include them in your main routing configuration. So, I like your
> solution a lot. It makes a lot of sense.
>
> One thing I also want to fix, and I'm not sure if your solution can
> solve it as is, is when the model classes are defined *outside* of the
> bundle hierarchy. One goal of the "Model" is to be reusable. So, you
> should be able to reuse your entities in a non-Symfony2 context. Right
> now, you are forced to define them in a bundle, which is tied to
> Symfony2 obviously (even if this is just a bunch of directories that
> define a namespace hierarchy).
>
> To sum up, I'm +1 on the change. If we can also find a solution for
> "non-bundled" entities, that would even be better.
>
> Fabien
--
If you want to report a vulnerability issue on symfony, please send it to
security at symfony-project.com
You received this message because you are subscribed to the Google
Groups "symfony developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/symfony-devs?hl=en