diff --git a/src/Plugin/search_api/processor/AddHierarchy.php b/src/Plugin/search_api/processor/AddHierarchy.php index 2ef94a2..b6f4bb8 100644 --- a/src/Plugin/search_api/processor/AddHierarchy.php +++ b/src/Plugin/search_api/processor/AddHierarchy.php @@ -14,7 +14,6 @@ use Drupal\search_api\Item\FieldInterface; use Drupal\search_api\Plugin\PluginFormTrait; use Drupal\search_api\Processor\ProcessorPluginBase; -use Drupal\search_api\Utility\FieldsHelperInterface; use Drupal\search_api\Utility\Utility; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -40,13 +39,6 @@ class AddHierarchy extends ProcessorPluginBase implements PluginFormInterface { protected $entityTypeManager; /** - * The fields helper. - * - * @var \Drupal\search_api\Utility\FieldsHelperInterface|null - */ - protected static $fieldsHelper; - - /** * {@inheritdoc} */ public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { @@ -54,32 +46,11 @@ public static function create(ContainerInterface $container, array $configuratio $processor = parent::create($container, $configuration, $plugin_id, $plugin_definition); $processor->setEntityTypeManager($container->get('entity_type.manager')); - static::setFieldsHelper($container->get('search_api.fields_helper')); return $processor; } /** - * Retrieves the fields helper. - * - * @return \Drupal\search_api\Utility\FieldsHelperInterface - * The fields helper. - */ - public static function getFieldsHelper() { - return static::$fieldsHelper ?: \Drupal::service('search_api.fields_helper'); - } - - /** - * Sets the fields helper. - * - * @param \Drupal\search_api\Utility\FieldsHelperInterface $fields_helper - * The new fields helper. - */ - public static function setFieldsHelper(FieldsHelperInterface $fields_helper) { - static::$fieldsHelper = $fields_helper; - } - - /** * Retrieves the entity type manager service. * * @return \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager @@ -139,7 +110,9 @@ protected static function getHierarchyFields(IndexInterface $index) { $properties[''] = $definition; foreach ($properties as $property) { $property_label = $property->getLabel(); - $property = static::$fieldsHelper->getInnerProperty($property); + $property = \Drupal::getContainer() + ->get('search_api.fields_helper') + ->getInnerProperty($property); if ($property instanceof EntityDataDefinitionInterface) { $options = self::findHierarchicalProperties($property, $property_label); if ($options) { @@ -182,11 +155,12 @@ protected static function getHierarchyFields(IndexInterface $index) { protected static function findHierarchicalProperties(EntityDataDefinitionInterface $property, $property_label) { $entity_type_id = $property->getEntityTypeId(); $options = array(); + $fields_helper = \Drupal::getContainer()->get('search_api.fields_helper'); // Check properties for potential hierarchy. foreach ($property->getPropertyDefinitions() as $name_2 => $property_2) { $property_2_label = $property_2->getLabel(); - $property_2 = static::$fieldsHelper->getInnerProperty($property_2); + $property_2 = $fields_helper->getInnerProperty($property_2); if ($property_2 instanceof EntityDataDefinitionInterface) { if ($property_2->getEntityTypeId() == $entity_type_id) { $options["$entity_type_id-$name_2"] = Html::escape($property_label . ' » ' . $property_2_label); @@ -194,7 +168,7 @@ protected static function findHierarchicalProperties(EntityDataDefinitionInterfa } elseif ($property_2 instanceof ComplexDataDefinitionInterface) { foreach ($property_2->getPropertyDefinitions() as $property_3) { - $property_3 = static::$fieldsHelper->getInnerProperty($property_3); + $property_3 = $fields_helper->getInnerProperty($property_3); if ($property_3 instanceof EntityDataDefinitionInterface) { if ($property_3->getEntityTypeId() == $entity_type_id) { $options["$entity_type_id-$name_2"] = Html::escape($property_label . ' » ' . $property_2_label);