You are here

public function PremiumContent::preIndexSave in Node Option Premium 8

Preprocesses the search index entity before it is saved.

This can, for example, be used to make sure fields needed by this processor are enabled on the index.

Overrides ProcessorPluginBase::preIndexSave

File

src/Plugin/search_api/processor/PremiumContent.php, line 125

Class

PremiumContent
Adds premium information to the indexes.

Namespace

Drupal\nopremium\Plugin\search_api\processor

Code

public function preIndexSave() {
  foreach ($this->index
    ->getDatasources() as $datasource_id => $datasource) {
    if ($datasource
      ->getEntityTypeId() == 'node') {
      $this
        ->ensureField($datasource_id, 'premium', 'boolean');
      $this
        ->ensureField($datasource_id, 'type', 'string');
      $this
        ->ensureField($datasource_id, 'uid', 'integer');
    }
  }
}