Download the PHP package steevanb/doctrine-entity-merger without Composer
On this page you can find all versions of the php package steevanb/doctrine-entity-merger. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download steevanb/doctrine-entity-merger
More information about steevanb/doctrine-entity-merger
Files in steevanb/doctrine-entity-merger
Package doctrine-entity-merger
Short Description Add hint MERGE_ENTITY to merge fields retrieved by many queries
License MIT
Informations about the package doctrine-entity-merger
doctrine-entity-merger
When you use PARTIAL in DQL, you retrive only fields you need, instead of all Entity fields.
But, if you execute 2 PARTIAL on same entity, but not same fields, you will have this problem :
You can use _steevanb\DoctrineEntityMerger\QueryHint::MERGEENTITY to define description in $foo1 :
Changelog
Installation
As doctrine-entity-merger use steevanb/doctrine-events, see how to install it (composer dependecy is added here, you don't need to add it for steevanb/doctrine-events) :
Add it to your composer.json :
Add EntityMergerSubscriber :
If you want to add MERGE_ENTITY hint to all of your queries, you can do this :
For example, if you are on a Symfony project, you can add it in AppKernel :
# app/AppKernel.php
use Doctrine\ORM\EntityManagerInterface;
use steevanb\DoctrineEntityMerger\QueryHint;
use steevanb\DoctrineEntityMerger\EventSubscriber\EntityMergerSubscriber;
class AppKernel
{
public function boot()
{
parent::boot();
foreach ($this->getContainer()->get('doctrine')->getManagers() as $manager) {
if ($manager instanceof EntityManagerInterface) {
// add hint MERGE_ENTITY to all your queries
$manager->getConfiguration()->setDefaultQueryHint(QueryHint::MERGE_ENTITY, true);
// add listener, who use steevanb/doctrine-events to change UnitOfWork::createEntity()
// to take into account MERGE_ENTITY hint
$manager->getEventManager()->addEventSubscriber(new EntityMergerSubscriber());
}
}
}
}
All versions of doctrine-entity-merger with dependencies
doctrine/orm Version ^2.4.8
steevanb/doctrine-events Version ^1.0