You are here

public function WebformTestEditorialController::libraries in Webform 6.x

Returns webform libraries.

Return value

array A renderable array containing webform libraries editorial.

1 string reference to 'WebformTestEditorialController::libraries'
webform_test_editorial.routing.yml in tests/modules/webform_test_editorial/webform_test_editorial.routing.yml
tests/modules/webform_test_editorial/webform_test_editorial.routing.yml

File

tests/modules/webform_test_editorial/src/Controller/WebformTestEditorialController.php, line 298

Class

WebformTestEditorialController
Provides route responses for webform editorial.

Namespace

Drupal\webform_test_editorial\Controller

Code

public function libraries() {

  // Header.
  $header = [
    [
      'data' => $this
        ->t('Name'),
      'width' => '10%',
    ],
    [
      'data' => $this
        ->t('Title'),
      'width' => '10%',
    ],
    [
      'data' => $this
        ->t('Description'),
      'width' => '40%',
    ],
    [
      'data' => $this
        ->t('Notes'),
      'width' => '40%',
    ],
  ];

  // Rows.
  $rows = [];
  $libraries = $this->librariesManager
    ->getLibraries();
  foreach ($libraries as $name => $library) {
    $rows[] = [
      'data' => [
        [
          'data' => $name,
        ],
        [
          'data' => '<a href="' . $library['homepage_url']
            ->toString() . '">' . $library['title'] . '</a>',
        ],
        [
          'data' => $library['description'],
        ],
        [
          'data' => $library['notes'],
        ],
      ],
    ];
  }
  $build = $this
    ->buildTable('Webform: Libraries editorial', $header, $rows);
  return $this
    ->response($build);
}