function ConfigTranslationMapperList::render

Same name and namespace in other branches
  1. 8.9.x core/modules/config_translation/src/Controller/ConfigTranslationMapperList.php \Drupal\config_translation\Controller\ConfigTranslationMapperList::render()
  2. 10 core/modules/config_translation/src/Controller/ConfigTranslationMapperList.php \Drupal\config_translation\Controller\ConfigTranslationMapperList::render()
  3. 11.x core/modules/config_translation/src/Controller/ConfigTranslationMapperList.php \Drupal\config_translation\Controller\ConfigTranslationMapperList::render()

Builds the mappers as a renderable array for table.html.twig.

Return value

array Renderable array with config translation mappers.

1 string reference to 'ConfigTranslationMapperList::render'
config_translation.routing.yml in core/modules/config_translation/config_translation.routing.yml
core/modules/config_translation/config_translation.routing.yml

File

core/modules/config_translation/src/Controller/ConfigTranslationMapperList.php, line 48

Class

ConfigTranslationMapperList
Defines the configuration translation mapper list.

Namespace

Drupal\config_translation\Controller

Code

public function render() {
    $build = [
        '#type' => 'table',
        '#header' => $this->buildHeader(),
        '#rows' => [],
    ];
    $mappers = [];
    foreach ($this->mappers as $mapper) {
        if ($row = $this->buildRow($mapper)) {
            $mappers[$mapper->getWeight()][] = $row;
        }
    }
    // Group by mapper weight and sort by label.
    ksort($mappers);
    foreach ($mappers as $weight => $mapper) {
        usort($mapper, function ($a, $b) {
            $a_title = isset($a['label']) ? $a['label'] : '';
            $b_title = isset($b['label']) ? $b['label'] : '';
            return strnatcasecmp($a_title, $b_title);
        });
        $mappers[$weight] = $mapper;
    }
    $build['#rows'] = array_merge([], ...$mappers);
    return $build;
}

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