You are here

public function Operations::render in Advanced Queue 8

Renders the field.

Parameters

\Drupal\views\ResultRow $values: The values retrieved from a single row of a view's query result.

Return value

string|\Drupal\Component\Render\MarkupInterface The rendered output. If the output is safe it will be wrapped in an object that implements MarkupInterface. If it is empty or unsafe it will be a string.

Overrides FieldPluginBase::render

File

src/Plugin/views/field/Operations.php, line 51

Class

Operations
Field handler to render operations available for a given job.

Namespace

Drupal\advancedqueue\Plugin\views\field

Code

public function render(ResultRow $values) {
  $operations = [];
  $state = $this
    ->getValue($values, 'state');
  $queue_id = $this
    ->getValue($values, 'queue_id');
  $job_id = $this
    ->getValue($values, 'job_id');
  if ($state === Job::STATE_PROCESSING) {
    $operations['release'] = [
      'title' => $this
        ->t('Release'),
      'weight' => -10,
      'url' => Url::fromRoute('advancedqueue.job.release', [
        'advancedqueue_queue' => $queue_id,
        'job_id' => $job_id,
      ]),
    ];
  }
  $operations['delete'] = [
    'title' => $this
      ->t('Delete'),
    'weight' => 0,
    'url' => Url::fromRoute('advancedqueue.job.delete', [
      'advancedqueue_queue' => $queue_id,
      'job_id' => $job_id,
    ]),
  ];
  $build = [
    '#type' => 'operations',
    '#links' => $operations,
  ];
  return $build;
}