Created
October 14, 2018 20:41
-
-
Save enumag/22c14d6a7bf55cf390ed44fd33dbd584 to your computer and use it in GitHub Desktop.
DeferredExplicitTrackingPolicySubscriber
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php declare(strict_types = 1); | |
namespace App\Library\Doctrine\Subscriber; | |
use Doctrine\Common\EventSubscriber; | |
use Doctrine\ORM\Event\LoadClassMetadataEventArgs; | |
use Doctrine\ORM\Events; | |
use Doctrine\ORM\Mapping\ClassMetadata; | |
final class DeferredExplicitTrackingPolicySubscriber implements EventSubscriber | |
{ | |
/** | |
* @return string[] | |
*/ | |
public function getSubscribedEvents(): array | |
{ | |
return [ | |
Events::loadClassMetadata, | |
]; | |
} | |
public function loadClassMetadata(LoadClassMetadataEventArgs $event): void | |
{ | |
$metadata = $event->getClassMetadata(); | |
$metadata->setChangeTrackingPolicy(ClassMetadata::CHANGETRACKING_DEFERRED_EXPLICIT); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment