Created
June 12, 2015 08:21
-
-
Save slashfan/707817b76dbf9576a350 to your computer and use it in GitHub Desktop.
Doctine PostRemove event and SoftDeleteable behavior
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 | |
/** | |
* @ORM\Entity | |
*/ | |
class Article | |
{ | |
// ... | |
} | |
class IndexerSuscriber implements EventSubscriber | |
{ | |
// .... | |
public function getSubscribedEvents() | |
{ | |
return [ | |
'postRemove' | |
]; | |
} | |
public function postRemove(LifecycleEventArgs $args) | |
{ | |
$this->indexer->deindex($args->getEntity()); | |
} | |
} |
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 | |
/** | |
* @ORM\Entity | |
* @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false) | |
*/ | |
class Article | |
{ | |
// ... | |
} | |
class IndexerSuscriber implements EventSubscriber | |
{ | |
// ... | |
public function getSubscribedEvents() | |
{ | |
return [ | |
'postSoftDelete' | |
]; | |
} | |
public function postSoftDelete(LifecycleEventArgs $args) | |
{ | |
$this->indexer->deindex($args->getEntity()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment