MaestroEngineProcessDetails.php in Maestro 8.2
File
src/Plugin/views/field/MaestroEngineProcessDetails.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 MaestroEngineProcessDetails extends FieldPluginBase {
public function query() {
}
protected function defineOptions() {
$options = parent::defineOptions();
$options['views_attached'] = [
'default' => '',
];
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();
}
$build = [];
$build['details'][$processID]['expand'] = [
'#prefix' => '<div class="maestro-process-details-expand-wrapper maestro-expand-wrapper maestro-status-toggle-' . $processID . '">',
'#suffix' => '</div>',
'#attributes' => [
'class' => [
'maestro-timeline-status',
'maestro-status-toggle',
],
'title' => $this
->t('Open Details'),
],
'#type' => 'link',
'#id' => 'maestro-id-ajax-' . $processID,
'#url' => Url::fromRoute('maestro.process_details_ajax_open', [
'processID' => $processID,
]),
'#title' => $this
->t('Open Details'),
'#ajax' => [
'progress' => [
'type' => 'throbber',
'message' => NULL,
],
],
];
$build['#attached']['library'][] = 'maestro/maestro-engine-css';
$build['#attached']['library'][] = 'maestro_taskconsole/maestro_taskconsole_css';
return $build;
}
}