function ConfigMapperManager::findTranslatable

Same name in other branches
  1. 8.9.x core/modules/config_translation/src/ConfigMapperManager.php \Drupal\config_translation\ConfigMapperManager::findTranslatable()
  2. 10 core/modules/config_translation/src/ConfigMapperManager.php \Drupal\config_translation\ConfigMapperManager::findTranslatable()
  3. 11.x core/modules/config_translation/src/ConfigMapperManager.php \Drupal\config_translation\ConfigMapperManager::findTranslatable()

Returns TRUE if at least one translatable element is found.

Parameters

\Drupal\Core\TypedData\TypedDataInterface $element: Configuration schema element.

Return value

bool A boolean indicating if there is at least one translatable element.

1 call to ConfigMapperManager::findTranslatable()
ConfigMapperManager::hasTranslatable in core/modules/config_translation/src/ConfigMapperManager.php
Returns TRUE if the configuration data has translatable items.

File

core/modules/config_translation/src/ConfigMapperManager.php, line 181

Class

ConfigMapperManager
Manages plugins for configuration translation mappers.

Namespace

Drupal\config_translation

Code

protected function findTranslatable(TypedDataInterface $element) {
    // In case this is a sequence or a mapping check whether any child element
    // is translatable.
    if ($element instanceof TraversableTypedDataInterface) {
        foreach ($element as $child_element) {
            if ($this->findTranslatable($child_element)) {
                return TRUE;
            }
        }
        // If none of the child elements are translatable, return FALSE.
        return FALSE;
    }
    else {
        $definition = $element->getDataDefinition();
        return isset($definition['translatable']) && $definition['translatable'];
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.