You are here

public function SiteName::addFieldValues in Search API Field Map 8

Same name and namespace in other branches
  1. 8.3 src/Plugin/search_api/processor/SiteName.php \Drupal\search_api_field_map\Plugin\search_api\processor\SiteName::addFieldValues()
  2. 8.2 src/Plugin/search_api/processor/SiteName.php \Drupal\search_api_field_map\Plugin\search_api\processor\SiteName::addFieldValues()
  3. 4.x src/Plugin/search_api/processor/SiteName.php \Drupal\search_api_field_map\Plugin\search_api\processor\SiteName::addFieldValues()

Adds the values of properties defined by this processor to the item.

Parameters

\Drupal\search_api\Item\ItemInterface $item: The item whose field values should be added.

Overrides ProcessorPluginBase::addFieldValues

File

src/Plugin/search_api/processor/SiteName.php, line 51

Class

SiteName
Adds the site name to the indexed data.

Namespace

Drupal\search_api_field_map\Plugin\search_api\processor

Code

public function addFieldValues(ItemInterface $item) {
  $fields = $this
    ->getFieldsHelper()
    ->filterForPropertyPath($item
    ->getFields(), NULL, 'site_name');
  if ($this
    ->useDomain()) {
    $entity = $item
      ->getOriginalObject()
      ->getValue();
    if ($entity instanceof EntityInterface) {
      $this
        ->addDomainName($item, $entity, $fields);
    }
  }
  else {
    foreach ($fields as $field) {
      $site_name = $field
        ->getConfiguration()['site_name'];
      $field
        ->addValue($site_name);
    }
  }
}