Last active
October 31, 2019 22:59
-
-
Save ismail1432/facae7e80fc839b1d339c2e38a6e8f75 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
class UserSubscriber | |
{ | |
public function postPersist(LifecycleEventArgs $args) | |
{ | |
$entity = $args->getObject(); | |
// if this listener only applies to certain entity types, | |
// add some code to check the entity type as early as possible | |
if (!$this->supports($entity)) { | |
return; | |
} | |
$entityManager = $args->getObjectManager(); | |
// ... do something with the User entity | |
} | |
public function supports($entity): bool | |
{ | |
return $entity instanceof User; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment