Skip to content

Commit b271a75

Browse files
authored
Merge pull request #14 from robbash/fix-elastic-index-not-removed-on-unpublish
fix(ElasticasSearchable): Set `liveIndex` when unpublishing a page
2 parents 6c9bb9f + 19ec3cc commit b271a75

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/ElasticaSearchable.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,15 @@ public function onAfterPublish() {
4444
$this->reIndex('Live');
4545
}
4646

47+
public function onBeforeUnpublish()
48+
{
49+
// We need to remove the `live` index from the search. Because we're not
50+
// going through the `reIndex` methods and the `getElasticaDocument` is
51+
// called from `Heyday\Elastica::remove`, we need to set the `liveIndex`
52+
// flage here.
53+
$this->liveIndex = true;
54+
}
55+
4756
public function getElasticaFields() {
4857
$result = parent::getElasticaFields();
4958

0 commit comments

Comments
 (0)