You are here

public function BUEditorController::buttonsOverview in BUEditor 8

Same name and namespace in other branches
  1. 8.2 src/Controller/BUEditorController.php \Drupal\bueditor\Controller\BUEditorController::buttonsOverview()

Returns an administrative overview of BUEditor Buttons.

1 string reference to 'BUEditorController::buttonsOverview'
bueditor.routing.yml in ./bueditor.routing.yml
bueditor.routing.yml

File

src/Controller/BUEditorController.php, line 29

Class

BUEditorController
Controller routines for bueditor routes.

Namespace

Drupal\bueditor\Controller

Code

public function buttonsOverview() {

  // Custom buttons
  $output['custom_buttons'] = [
    '#type' => 'container',
    '#attributes' => [
      'class' => [
        'bueditor-button-list bbl-custom',
      ],
    ],
    'title' => [
      '#markup' => '<h2>' . $this
        ->t('Custom buttons') . '</h2>',
    ],
    'list' => $this
      ->entityTypeManager()
      ->getListBuilder('bueditor_button')
      ->render(),
  ];

  // Plugin buttons
  $groups = [];
  $header = [
    [
      'data' => $this
        ->t('ID'),
      'class' => 'button-id',
    ],
    [
      'data' => $this
        ->t('Name'),
      'class' => 'button-label',
    ],
  ];
  foreach (\Drupal::service('plugin.manager.bueditor.plugin')
    ->getButtonGroups() as $key => $group) {
    $rows = [];
    foreach ($group['buttons'] as $bid => $data) {
      $rows[] = [
        $bid,
        isset($data['label']) ? $data['label'] : '',
      ];
    }
    $groups[$key] = [
      '#theme' => 'table',
      '#header' => $header,
      '#rows' => $rows,
      '#caption' => $group['label'],
      '#attributes' => [
        'class' => [
          'bueditor-button-group bbg-' . $key,
        ],
      ],
    ];
  }
  $output['plugin_buttons'] = [
    '#type' => 'details',
    '#attributes' => [
      'class' => [
        'bueditor-button-list bbl-plugins',
      ],
    ],
    '#title' => $this
      ->t('Plugin buttons'),
    'list' => $groups,
  ];
  $output['#attached']['library'][] = 'bueditor/drupal.bueditor.admin';
  return $output;
}