MaestroEngineAdminOperations.php in Maestro 8.2
File
src/Plugin/views/field/MaestroEngineAdminOperations.php
View source
<?php
namespace Drupal\maestro\Plugin\views\field;
use Drupal\Core\Form\FormStateInterface;
use Drupal\maestro\Engine\MaestroEngine;
use Drupal\views\Plugin\views\field\FieldPluginBase;
use Drupal\views\ResultRow;
use Drupal\Core\Url;
class MaestroEngineAdminOperations extends FieldPluginBase {
public function query() {
}
protected function defineOptions() {
$options = parent::defineOptions();
return $options;
}
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
}
public function render(ResultRow $values) {
$item = $values->_entity;
$rows = [];
$links = [];
$processID = 0;
if ($item
->getEntityTypeId() == 'maestro_production_assignments') {
$queueRecord = MaestroEngine::getQueueEntryById($item->queue_id
->getString());
$processID = $queueRecord->process_id
->getString();
}
elseif ($item
->getEntityTypeId() == 'maestro_queue') {
$processID = $item->process_id
->getString();
}
elseif ($item
->getEntityTypeId() == 'maestro_process') {
$processID = $item->process_id
->getString();
}
$links['trace'] = [
'title' => t('Trace'),
'url' => Url::fromRoute('maestro.trace', [
'processID' => $processID,
]),
];
$assignees = [];
if ($item
->getEntityTypeId() == 'maestro_production_assignments') {
$assignees = MaestroEngine::getAssignedNamesOfQueueItem($item->queue_id
->getString(), TRUE);
}
elseif ($item
->getEntityTypeId() == 'maestro_queue') {
$assignees = MaestroEngine::getAssignedNamesOfQueueItem($item->id
->getString(), TRUE);
}
foreach ($assignees as $name => $assignment) {
$links[$name] = [
'title' => t('Reassign') . ' ' . $name,
'url' => Url::fromRoute('maestro.reassign_task', [
'assignmentID' => $assignment['id'],
]),
];
}
$rows[] = [
'data' => [
'#type' => 'operations',
'#links' => $links,
],
];
return $rows;
}
}