You are here

public function CustomFormattersController::addList in Custom Formatters 8.3

Displays add content links for available formatter types.

Return value

array|\Symfony\Component\HttpFoundation\RedirectResponse A render array for a list of the formatter types that can be added; however, if there is only one formatter type available for the user, the function will return a RedirectResponse to the formatter add page for that one formatter type.

1 string reference to 'CustomFormattersController::addList'
custom_formatters.routing.yml in ./custom_formatters.routing.yml
custom_formatters.routing.yml

File

src/Controller/CustomFormattersController.php, line 66

Class

CustomFormattersController
Class CustomFormattersController.

Namespace

Drupal\custom_formatters\Controller

Code

public function addList() {
  $build = [
    '#theme' => 'formatter_add_list',
  ];
  $content = [];

  // Only use formatter types the user has access to.
  // @TODO - Add granular permissions system.
  foreach ($this->formatterTypeManager
    ->getDefinitions() as $formatter_type) {
    $content[$formatter_type['id']] = $formatter_type;
  }
  $build['#content'] = $content;
  return $build;
}