You are here

protected function Index::writeChangesToSettings in Search API 8

Prepares for changes to this index to be persisted.

To this end, the settings for all loaded field and plugin objects are written back to the corresponding *_settings properties.

Return value

$this

2 calls to Index::writeChangesToSettings()
Index::preSave in src/Entity/Index.php
Acts on an entity before the presave hook is invoked.
Index::__sleep in src/Entity/Index.php
Implements the magic __sleep() method.

File

src/Entity/Index.php, line 1332

Class

Index
Defines the search index configuration entity.

Namespace

Drupal\search_api\Entity

Code

protected function writeChangesToSettings() {

  // Calculate field dependencies and save field settings containing them.
  $fields = $this
    ->getFields();
  $field_dependencies = $this
    ->getFieldDependencies();
  $field_dependencies += array_fill_keys(array_keys($fields), []);
  $this->field_settings = [];
  foreach ($fields as $field_id => $field) {
    $field
      ->setDependencies($field_dependencies[$field_id]);
    $this->field_settings[$field_id] = $field
      ->getSettings();
  }

  // Write the enabled processors to the settings property.
  $processors = $this
    ->getProcessors();
  $this->processor_settings = [];
  foreach ($processors as $processor_id => $processor) {
    $this->processor_settings[$processor_id] = $processor
      ->getConfiguration();
  }

  // Write the tracker configuration to the settings property.
  $tracker = $this
    ->getTrackerInstance();
  $tracker_id = $tracker
    ->getPluginId();
  $this->tracker_settings = [
    $tracker_id => $tracker
      ->getConfiguration(),
  ];

  // Write the enabled datasources to the settings array.
  $this->datasource_settings = [];
  foreach ($this
    ->getDatasources() as $plugin_id => $datasource) {
    $this->datasource_settings[$plugin_id] = $datasource
      ->getConfiguration();
  }
  return $this;
}