diff --git a/src/Plugin/search_api/processor/AddHierarchy.php b/src/Plugin/search_api/processor/AddHierarchy.php index cb78e77..75d1cb0 100644 --- a/src/Plugin/search_api/processor/AddHierarchy.php +++ b/src/Plugin/search_api/processor/AddHierarchy.php @@ -7,8 +7,10 @@ use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Entity\Plugin\DataType\EntityAdapter; use Drupal\Core\Field\FieldStorageDefinitionInterface; use Drupal\Core\Form\FormStateInterface; +use Drupal\Core\Plugin\PluginFormInterface; use Drupal\search_api\Item\FieldInterface; use Drupal\search_api\Item\ItemInterface; +use Drupal\search_api\Plugin\PluginFormTrait; use Drupal\search_api\Processor\ProcessorPluginBase; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -22,7 +24,9 @@ use Symfony\Component\DependencyInjection\ContainerInterface; * } * ) */ -class AddHierarchy extends ProcessorPluginBase { +class AddHierarchy extends ProcessorPluginBase implements PluginFormInterface { + + use PluginFormTrait; /** * The entity type manager. @@ -79,8 +83,6 @@ class AddHierarchy extends ProcessorPluginBase { * {@inheritdoc} */ public function buildConfigurationForm(array $form, FormStateInterface $form_state) { - $form = parent::buildConfigurationForm($form, $form_state); - $field_options = array(); foreach ($this->index->getFields() as $field_id => $field) { if ($this->isEntityReferenceField($field)) { @@ -103,8 +105,6 @@ class AddHierarchy extends ProcessorPluginBase { * {@inheritdoc} */ public function validateConfigurationForm(array &$form, FormStateInterface $form_state) { - parent::validateConfigurationForm($form, $form_state); - $fields = array_filter($form_state->getValues()['fields']); if ($fields) { $fields = array_keys($fields); @@ -119,7 +119,7 @@ class AddHierarchy extends ProcessorPluginBase { /** @var \Drupal\search_api\Item\ItemInterface $item */ foreach ($items as $item) { foreach ($item->getFields() as $field) { - if ($this->isEntityReferenceField($field) && in_array($field->getFieldIdentifier(), $this->configuration['fields'])) { + if (in_array($field->getFieldIdentifier(), $this->configuration['fields'])) { // The field is an entity reference, so we have to traverse up the // tree to find all parents. $hierarchyValues = array();