You are here

protected function ReplicationListBuilder::getReplicationStatusIcon in Deploy - Content Staging 8

1 call to ReplicationListBuilder::getReplicationStatusIcon()
ReplicationListBuilder::buildRow in src/ReplicationListBuilder.php
Builds a row for an entity in the entity listing.

File

src/ReplicationListBuilder.php, line 117

Class

ReplicationListBuilder
Defines a class to build a listing of Replication entities.

Namespace

Drupal\deploy

Code

protected function getReplicationStatusIcon($status, $id) {
  $status = (int) $status;
  $icons = [
    Replication::QUEUED => $this
      ->t('&#x231A Queued'),
    Replication::REPLICATING => $this
      ->t('In progress'),
    Replication::REPLICATED => $this
      ->t('✔ Done'),
  ];
  if ($status === Replication::FAILED) {
    $link_url = Url::fromUserInput('/admin/structure/deployment/' . $id . '/fail-info');
    $link_url
      ->setOptions(array(
      'attributes' => array(
        'class' => array(
          'use-ajax',
        ),
        'data-dialog-type' => 'modal',
        'data-dialog-options' => Json::encode(array(
          'width' => 700,
        )),
      ),
    ));
    $icons[Replication::FAILED] = Link::fromTextAndUrl($this
      ->t('✖ Failed'), $link_url);
  }

  /** @var Replication $entity */
  $entity = $this
    ->getStorage()
    ->load($id);
  if ($status === Replication::QUEUED && !empty($entity
    ->getReplicationFailInfo())) {
    $link_url = Url::fromUserInput('/admin/structure/deployment/' . $id . '/requeue-info');
    $link_url
      ->setOptions(array(
      'attributes' => array(
        'class' => array(
          'use-ajax',
        ),
        'data-dialog-type' => 'modal',
        'data-dialog-options' => Json::encode(array(
          'width' => 700,
        )),
      ),
    ));
    $icons[Replication::QUEUED] = Link::fromTextAndUrl($this
      ->t('&#x231A Queued'), $link_url);
  }
  return $icons[$status];
}