From a192066dd8b0365798c69ca97a8a1f4ce94fca75 Mon Sep 17 00:00:00 2001 From: Jere Ljungberg Date: Tue, 20 Dec 2022 12:00:54 +0200 Subject: [PATCH] UHF-5254: Remove unused code --- conf/cmi/search_api.index.job_listings.yml | 1 - .../search_api/processor/Employment.php | 115 ------------------ 2 files changed, 116 deletions(-) delete mode 100644 public/modules/custom/helfi_rekry_job_search/src/Plugin/search_api/processor/Employment.php diff --git a/conf/cmi/search_api.index.job_listings.yml b/conf/cmi/search_api.index.job_listings.yml index ca10f375..4263bea2 100644 --- a/conf/cmi/search_api.index.job_listings.yml +++ b/conf/cmi/search_api.index.job_listings.yml @@ -245,7 +245,6 @@ datasource_settings: processor_settings: add_url: { } aggregated_field: { } - employment: { } entity_status: { } entity_type: { } ignorecase: diff --git a/public/modules/custom/helfi_rekry_job_search/src/Plugin/search_api/processor/Employment.php b/public/modules/custom/helfi_rekry_job_search/src/Plugin/search_api/processor/Employment.php deleted file mode 100644 index cfde8597..00000000 --- a/public/modules/custom/helfi_rekry_job_search/src/Plugin/search_api/processor/Employment.php +++ /dev/null @@ -1,115 +0,0 @@ - $this->t('Employment'), - 'description' => $this->t('Generates a list of valid employment filter values'), - 'type' => 'nested', - 'processor_id' => $this->getPluginId(), - 'hidden' => FALSE, - ]; - $properties['employment'] = new ProcessorProperty($definition); - } - - return $properties; - } - - /** - * {@inheritdoc} - */ - public function addFieldValues(ItemInterface $item) { - $datasourceId = $item->getDataSourceId(); - $employments; - $employment_types; - $values = []; - - if ($datasourceId === 'entity:node' && $node = $item->getOriginalObject()->getValue()) { - $employments = $this->getValidValues($node->get('field_employment')->referencedEntities(), self::VALID_EMPLOYMENTS); - $employment_types = $this->getValidValues($node->get('field_employment_type')->referencedEntities(), self::VALID_EMPLOYMENT_TYPES); - } - - if ($employments) { - $values = array_merge($values, $employments); - } - - if ($employment_types) { - $values = array_merge($values, $employment_types); - } - - $fields = $this->getFieldsHelper()->filterForPropertyPath($item->getFields(), 'entity:node', 'employment'); - if (isset($fields['employment'])) { - $fields['employment']->setValues($values); - } - } - - /** - * Return a list of accepted values (if present). - * - * @param \Drupal\taxonomy\TermInterface[] $terms - * Array of values attached to the node. - * @param array $valid_values - * Array of valid values to check against. - * - * @return array - * Array of found valid values. - */ - public function getValidValues(array $terms, array $valid_values): array { - $found = []; - - if (!is_array($terms) || !count($terms)) { - return $found; - } - - foreach ($terms as $term) { - $tid = $term->id(); - if (in_array($tid, $valid_values)) { - $found[] = [ - 'id' => $tid, - 'name' => $term->getName(), - ]; - } - } - - return $found; - } - -}