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

DriverChain usage example (Multiple metadata source) #2

Open
hkulekci opened this issue Jun 14, 2016 · 0 comments
Open

DriverChain usage example (Multiple metadata source) #2

hkulekci opened this issue Jun 14, 2016 · 0 comments

Comments

@hkulekci
Copy link
Member

hkulekci commented Jun 14, 2016

from the documentation :

Multiple Metadata Sources

When using different components with Doctrine 2, you may end up with them using two different metadata drivers, for example, XML and YAML. You can use the DriverChain Metadata implementations to aggregate these drivers based on namespaces:

<?php
use Doctrine\ORM\Mapping\Driver\DriverChain;

$chain = new DriverChain();
$chain->addDriver($xmlDriver, 'Doctrine\Tests\Models\Company');
$chain->addDriver($yamlDriver, 'Doctrine\Tests\ORM\Mapping');

Based on the namespace of the entity the loading of entities is delegated to the appropriate driver. The chain semantics come from the fact that the driver loops through all namespaces and matches the entity class name against the namespace using a strpos() === 0 call. This means you need to order the drivers correctly if sub-namespaces use different metadata driver implementations.

@hkulekci hkulekci changed the title Multiple Metadata Feature Implementation Multiple Metadata Source Feature Implementation Jun 14, 2016
@hkulekci hkulekci changed the title Multiple Metadata Source Feature Implementation Multiple Metadata Source FeatureUsage Implementation Jun 14, 2016
@edigu edigu changed the title Multiple Metadata Source FeatureUsage Implementation DriverChain implementation example (Multiple metadata source) Jun 14, 2016
@edigu edigu changed the title DriverChain implementation example (Multiple metadata source) DriverChain usage example (Multiple metadata source) Jun 14, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant