You are here

public function MaestroInteractiveTask::performValidityCheck in Maestro 3.x

Same name and namespace in other branches
  1. 8.2 src/Plugin/EngineTasks/MaestroInteractiveTask.php \Drupal\maestro\Plugin\EngineTasks\MaestroInteractiveTask::performValidityCheck()

Lets the task perform validation on itself. If the task is missing any internal requirements, it can flag itself as having an issue. Return array MUST be in the format of array( 'taskID' => the task machine name, 'taskLabel' => the human readable label for the task, 'reason' => the reason for the failure )

Parameters

array $validation_failure_tasks: The array of other validation failures.

array $validation_information_tasks: The array of informational messages.

array $task: The passed-in fully-loaded task from the template (array)

Overrides MaestroEngineTaskInterface::performValidityCheck

File

src/Plugin/EngineTasks/MaestroInteractiveTask.php, line 321

Class

MaestroInteractiveTask
Maestro Interactive Task Plugin.

Namespace

Drupal\maestro\Plugin\EngineTasks

Code

public function performValidityCheck(array &$validation_failure_tasks, array &$validation_information_tasks, array $task) {

  // Pretty simple -- just ensure that there's a handler and modal set.
  if (array_key_exists('handler', $task) && $task['handler'] == '' || !array_key_exists('handler', $task)) {
    $validation_information_tasks[] = [
      'taskID' => $task['id'],
      'taskLabel' => $task['label'],
      'reason' => t('The Interactive Task handler is missing and thus the engine will assign the default handler to this task.'),
    ];
  }
  if (array_key_exists('modal', $task['data']) && $task['data']['modal'] == '' || !array_key_exists('modal', $task['data'])) {
    $validation_failure_tasks[] = [
      'taskID' => $task['id'],
      'taskLabel' => $task['label'],
      'reason' => t('The Interactive Task has not been set up properly.  The "Task Presentation" option is missing and thus the engine will be unable to execute this task.'),
    ];
  }

  // This task should have assigned users
  // $task['assigned'] should have data.
  if (array_key_exists('assigned', $task) && $task['assigned'] == '' || !array_key_exists('assigned', $task)) {
    $validation_failure_tasks[] = [
      'taskID' => $task['id'],
      'taskLabel' => $task['label'],
      'reason' => t('The Interactive Task has not been set up properly.  The Interactive Task requires assignments to actors, roles or other assignment options.'),
    ];
  }
}