public static function getStateDefinitions() {
if (!empty(static::$stateDefinitions)) {
return static::$stateDefinitions;
}
static::$stateDefinitions = [
static::STATE_ACTIVE => [
'label' => t('In progress'),
'type' => 'state',
'icon' => \Drupal::service('extension.list.module')
->getPath('tmgmt') . '/icons/hourglass.svg',
'weight' => 0,
'show_job_filter' => TRUE,
],
static::STATE_REVIEW => [
'label' => t('Needs review'),
'type' => 'state',
'icon' => \Drupal::service('extension.list.module')
->getPath('tmgmt') . '/icons/ready.svg',
'weight' => 5,
'show_job_filter' => TRUE,
],
static::STATE_ACCEPTED => [
'label' => t('Accepted'),
'type' => 'state',
'weight' => 10,
],
static::STATE_ABORTED => [
'label' => t('Aborted'),
'type' => 'state',
'weight' => 15,
],
static::STATE_INACTIVE => [
'label' => t('Inactive'),
'type' => 'state',
'icon' => \Drupal::service('extension.list.module')
->getPath('tmgmt') . '/icons/rejected.svg',
'weight' => 20,
],
];
\Drupal::moduleHandler()
->alter('tmgmt_job_item_state_definitions', static::$stateDefinitions);
foreach (static::$stateDefinitions as $key => &$definition) {
// Ensure that all state definitions have a type and label key set.
assert(!empty($definition['type']) && !empty($definition['label']), "State definition {$key} is missing label or type.");
// Set the default weight to 25, after the default states.
$definition += [
'weight' => 25,
];
}
uasort(static::$stateDefinitions, [
SortArray::class,
'sortByWeightElement',
]);
return static::$stateDefinitions;
}