ScheduledTransitionToStateViewsField.php in Scheduled Transitions 2.x
File
src/Plugin/views/field/ScheduledTransitionToStateViewsField.php
View source
<?php
declare (strict_types=1);
namespace Drupal\scheduled_transitions\Plugin\views\field;
use Drupal\views\Plugin\views\field\FieldPluginBase;
use Drupal\views\ResultRow;
class ScheduledTransitionToStateViewsField extends FieldPluginBase {
public function render(ResultRow $values) {
$value = $this
->getValue($values);
$scheduledTransition = $this
->getEntity($values);
$workflowPlugin = $scheduledTransition
->getWorkflow()
->getTypePlugin();
$workflowStates = $workflowPlugin ? $workflowPlugin
->getStates() : [];
$fromState = $workflowStates[$value] ?? NULL;
return $fromState ? $fromState
->label() : $this
->t('- Missing to workflow/state -');
}
}