You are here

public function ConfigSourcePluginUi::getFilteredSimpleConfigDefinitions in Translation Management Tool 8

Filter translatable definitions.

Parameters

array $search_properties: Search properties that are going to be used for the filter.

Return value

\Drupal\Core\Entity\EntityTypeInterface[] Array of translatable definitions.

1 call to ConfigSourcePluginUi::getFilteredSimpleConfigDefinitions()
ConfigSourcePluginUi::overviewForm in sources/tmgmt_config/src/ConfigSourcePluginUi.php
Builds the overview form for the source entities.

File

sources/tmgmt_config/src/ConfigSourcePluginUi.php, line 332

Class

ConfigSourcePluginUi
Config source plugin UI.

Namespace

Drupal\tmgmt_config

Code

public function getFilteredSimpleConfigDefinitions($search_properties = array()) {
  $definitions = \Drupal::service('plugin.manager.config_translation.mapper')
    ->getDefinitions();
  $definitions = array_filter($definitions, function ($definition) use ($search_properties) {
    if (isset($definition['entity_type'])) {
      return FALSE;
    }
    if (isset($search_properties['name']) && strpos(strtolower($definition['title']), strtolower($search_properties['name'])) === FALSE) {
      return FALSE;
    }
    if (isset($search_properties['target_language'])) {
      if ($search_properties['target_status'] == 'translated' && !$this
        ->isTranslated($search_properties['target_language'], $definition['names'][0])) {
        return FALSE;
      }
      if ($search_properties['target_status'] == 'untranslated' && $this
        ->isTranslated($search_properties['target_language'], $definition['names'][0])) {
        return FALSE;
      }
    }
    return TRUE;
  });
  return $definitions;
}