You are here

public function LingotekFilterManager::getFilterId in Lingotek Translation 3.8.x

Same name and namespace in other branches
  1. 8.2 src/LingotekFilterManager.php \Drupal\lingotek\LingotekFilterManager::getFilterId()
  2. 4.0.x src/LingotekFilterManager.php \Drupal\lingotek\LingotekFilterManager::getFilterId()
  3. 3.0.x src/LingotekFilterManager.php \Drupal\lingotek\LingotekFilterManager::getFilterId()
  4. 3.1.x src/LingotekFilterManager.php \Drupal\lingotek\LingotekFilterManager::getFilterId()
  5. 3.2.x src/LingotekFilterManager.php \Drupal\lingotek\LingotekFilterManager::getFilterId()
  6. 3.3.x src/LingotekFilterManager.php \Drupal\lingotek\LingotekFilterManager::getFilterId()
  7. 3.4.x src/LingotekFilterManager.php \Drupal\lingotek\LingotekFilterManager::getFilterId()
  8. 3.5.x src/LingotekFilterManager.php \Drupal\lingotek\LingotekFilterManager::getFilterId()
  9. 3.6.x src/LingotekFilterManager.php \Drupal\lingotek\LingotekFilterManager::getFilterId()
  10. 3.7.x src/LingotekFilterManager.php \Drupal\lingotek\LingotekFilterManager::getFilterId()

Gets the filter that should be applied.

Given filter provider can take precedence, or the settings default will be applied.

Parameters

\Drupal\lingotek\LingotekFilterProviderInterface|null $profile: A filter provider.

Return value

string The filter ID.

Overrides LingotekFilterManagerInterface::getFilterId

File

src/LingotekFilterManager.php, line 94

Class

LingotekFilterManager
Service for managing Lingotek Filters.

Namespace

Drupal\lingotek

Code

public function getFilterId(LingotekFilterProviderInterface $profile = NULL) {
  $defaults = new LingotekDefaultFilterProvider();
  $defaultFilter = $defaults
    ->getFilter();
  $filter = NULL;
  $settingsFilter = $this
    ->getDefaultFilter();
  if ($profile !== NULL && ($profileFilter = $profile
    ->getFilter())) {
    switch ($profileFilter) {
      case 'project_default':
        $filter = NULL;
        break;
      case 'drupal_default':
        $filter = $defaultFilter;
        break;
      case 'default':
        $filter = $this
          ->chooseAppropriateFilterID($settingsFilter, $defaultFilter);
        break;
      default:
        $filter = $profileFilter;
        break;
    }
  }
  else {
    $filter = $this
      ->chooseAppropriateFilterID($settingsFilter, $defaultFilter);
  }
  return $filter;
}