You are here

public function ContentHubExportQueueMessageSubscriber::kernelRequest in Acquia Content Hub 8

Handles kernel.request events.

Parameters

\Symfony\Component\EventDispatcher\Event $event: The Symfony event.

File

src/EventSubscriber/ContentHubExportQueueMessageSubscriber.php, line 76

Class

ContentHubExportQueueMessageSubscriber
Class ContentHubExportQueueMessageSubscriber.

Namespace

Drupal\acquia_contenthub\EventSubscriber

Code

public function kernelRequest(Event $event) {

  // Get our saved config data.
  $queue_items = $this->contentHubExportQueueController
    ->getQueueCount();

  // Get current path.
  $current_path = $this->currentPath
    ->getPath();

  // If we are processing the queue, then drop warning messages so they will
  // not pile up at every queue run.
  if ($current_path === '/admin/config/services/acquia-contenthub/export-queue') {
    $this->messenger
      ->messagesByType('warning');
  }
  if ($this
    ->currentUser()
    ->hasPermission('administer acquia content hub') && $queue_items > 1) {
    $message = $this
      ->t('You have %items items in the <a href="@link">Content Hub Export Queue</a>. Make sure to export those items to keep your system up to date.', [
      '%items' => $queue_items,
      '@link' => '/admin/config/services/acquia-contenthub/export-queue',
    ]);
    $this->messenger
      ->addWarning($message);
  }
}