/** * Checks whether the index switched server and reacts accordingly. * * Used as a helper method in postSave(). Should only be called when the index * was enabled before the change and remained so. * * @param \Drupal\search_api\IndexInterface $original * The previous version of the index. */ protected function reactToServerSwitch(IndexInterface $original) { if ($this->getServerId() != $original->getServerId()) { if ($original->isServerEnabled()) { $original->getServer()->removeIndex($this); } if ($this->isServerEnabled()) { $this->getServer()->addIndex($this); } // When the server changes we also need to trigger a reindex. $this->reindex(); } elseif ($this->isServerEnabled()) { // Tell the server the index configuration got updated $this->getServer()->updateIndex($this); } }
/** * Checks whether the index switched server and reacts accordingly. * * Used as a helper method in postSave(). Should only be called when the index * was enabled before the change and remained so. * * @param \Drupal\search_api\IndexInterface $original * The previous version of the index. */ protected function reactToServerSwitch(IndexInterface $original) { // Asserts that the index was enabled before saving and will still be // enabled afterwards. Otherwise, this method should not be called. assert('$this->status() && $original->status()', '::reactToServerSwitch should only be called when the index is enabled'); if ($this->getServerId() != $original->getServerId()) { if ($original->isServerEnabled()) { $original->getServerInstance()->removeIndex($this); } if ($this->isServerEnabled()) { $this->getServerInstance()->addIndex($this); } // When the server changes we also need to trigger a reindex. $this->reindex(); } elseif ($this->isServerEnabled()) { // Tell the server the index configuration got updated $this->getServerInstance()->updateIndex($this); } }
/** * {@inheritdoc} */ public function isServerEnabled() { return $this->entity->isServerEnabled(); }