You are here

function deploy_toolbar in Deploy - Content Staging 8

Implements hook_toolbar().

File

./deploy.module, line 13
UI module to deploy content entities.

Code

function deploy_toolbar() {
  $user = \Drupal::currentUser();
  $items['deploy'] = [
    '#type' => 'toolbar_item',
    'tab' => [
      '#type' => 'link',
      '#title' => t('Deploy'),
      '#url' => Url::fromRoute('entity.replication.add_form'),
      '#access' => \Drupal::entityTypeManager()
        ->getAccessControlHandler('replication')
        ->createAccess('', $user),
      '#attributes' => [
        'title' => t('Deploy'),
        'class' => [
          'toolbar-icon',
          'toolbar-icon-deploy',
          'use-ajax',
        ],
        'data-dialog-type' => 'modal',
        'data-dialog-options' => json_encode([
          'width' => '50%',
        ]),
      ],
    ],
    '#wrapper_attributes' => [
      'class' => [
        'deploy-toolbar-tab',
      ],
    ],
    '#attached' => [
      'library' => [
        'deploy/drupal.deploy.toolbar',
      ],
    ],
  ];
  return $items;
}