You are here

class FieldTypeToSynonyms in Synonyms 8

Same name and namespace in other branches
  1. 2.0.x src/SynonymsService/FieldTypeToSynonyms.php \Drupal\synonyms\SynonymsService\FieldTypeToSynonyms

Service to map known field types to how synonyms are encoded in them.

Hierarchy

Expanded class hierarchy of FieldTypeToSynonyms

3 files declare their use of FieldTypeToSynonyms
BaseField.php in src/Plugin/Synonyms/Provider/BaseField.php
Field.php in src/Plugin/Derivative/Field.php
Field.php in src/Plugin/Synonyms/Provider/Field.php
1 string reference to 'FieldTypeToSynonyms'
synonyms.services.yml in ./synonyms.services.yml
synonyms.services.yml
1 service uses FieldTypeToSynonyms
synonyms.provider.field_type_to_synonyms in ./synonyms.services.yml
Drupal\synonyms\SynonymsService\FieldTypeToSynonyms

File

src/SynonymsService/FieldTypeToSynonyms.php, line 10

Namespace

Drupal\synonyms\SynonymsService
View source
class FieldTypeToSynonyms {

  /**
   * The module handler.
   *
   * @var \Drupal\Core\Extension\ModuleHandlerInterface
   */
  protected $moduleHandler;

  /**
   * FieldTypeToSynonyms constructor.
   */
  public function __construct(ModuleHandlerInterface $module_handler) {
    $this->moduleHandler = $module_handler;
  }

  /**
   * Map field types to the properties within them where synonyms are stored.
   *
   * @return array
   *   Map where keys are simple field types and values are the properties where
   *   the corresponding field type keeps the synonyms
   */
  public function getSimpleFieldTypeToPropertyMap() {
    $map = [
      'integer' => 'value',
      'float' => 'value',
      'decimal' => 'value',
      'string' => 'value',
      'email' => 'value',
      'telephone' => 'value',
    ];
    $this->moduleHandler
      ->alter('synonyms_field_type_to_synonym', $map);
    return $map;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
FieldTypeToSynonyms::$moduleHandler protected property The module handler.
FieldTypeToSynonyms::getSimpleFieldTypeToPropertyMap public function Map field types to the properties within them where synonyms are stored.
FieldTypeToSynonyms::__construct public function FieldTypeToSynonyms constructor.