You are here

trait ConfigIdEscapeTrait in Search API sorts 8

Wrapper methods for \Drupal\search_api_sorts\SearchApiSortsField.

Using this trait will add escapeConfigId() and unescapeConfigId() methods to the class. These must be used for every config id when working loading or saving configuration entities. This allows derivative ids, which containing a colon, to be saved as config ids.

Hierarchy

3 files declare their use of ConfigIdEscapeTrait
AdminController.php in src/Controller/AdminController.php
ManageSortFieldsForm.php in src/Form/ManageSortFieldsForm.php
SearchApiSortsBlock.php in src/Plugin/Block/SearchApiSortsBlock.php

File

src/ConfigIdEscapeTrait.php, line 13

Namespace

Drupal\search_api_sorts
View source
trait ConfigIdEscapeTrait {

  /**
   * Escape a config id which can be used to save as a config entity.
   */
  protected function getEscapedConfigId($original_config_id) {
    return str_replace(':', '---', $original_config_id);
  }

  /**
   * Get original config id after loading a config entity using an escaped id.
   */
  protected function getOriginalConfigId($escaped_config_id) {
    return str_replace('---', ':', $escaped_config_id);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ConfigIdEscapeTrait::getEscapedConfigId protected function Escape a config id which can be used to save as a config entity.
ConfigIdEscapeTrait::getOriginalConfigId protected function Get original config id after loading a config entity using an escaped id.