You are here

function maestro_node_view_alter in Maestro 8.2

Same name and namespace in other branches
  1. 3.x maestro.module \maestro_node_view_alter()

Implements hook_node_view_alter().

File

./maestro.module, line 271
Provides glue logic, hook implementation and core set process variable functions.

Code

function maestro_node_view_alter(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display) {
  $queueID = intval(\Drupal::request()->query
    ->get('queueid', 0));
  $isMaestro = intval(\Drupal::request()->query
    ->get('maestro', 0));
  if ($display
    ->getEntityTypeId() == 'entity_view_display' && $isMaestro > 0 && $queueID > 0 && MaestroEngine::canUserExecuteTask($queueID, \Drupal::currentUser()
    ->id())) {
    $task = MaestroEngine::getTemplateTaskByQueueID($queueID);
    if ($task['tasktype'] == 'MaestroContentType' && isset($task['data']['show_maestro_buttons_on_view']) && $task['data']['show_maestro_buttons_on_view'] == 1) {
      $build['maestro_form'] = \Drupal::formBuilder()
        ->getForm('Drupal\\maestro\\Form\\MaestroContentTypeCompleteTask', $queueID);
      $build['maestro_form']['#weight'] = 1000;
    }
  }
}