Skip to content

Instantly share code, notes, and snippets.

@slashfan
Created June 12, 2015 08:21
Show Gist options
  • Save slashfan/707817b76dbf9576a350 to your computer and use it in GitHub Desktop.
Save slashfan/707817b76dbf9576a350 to your computer and use it in GitHub Desktop.
Doctine PostRemove event and SoftDeleteable behavior
<?php
/**
* @ORM\Entity
*/
class Article
{
// ...
}
class IndexerSuscriber implements EventSubscriber
{
// ....
public function getSubscribedEvents()
{
return [
'postRemove'
];
}
public function postRemove(LifecycleEventArgs $args)
{
$this->indexer->deindex($args->getEntity());
}
}
<?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