You are here

public function MaestroContentTypeCompleteTask::buildForm in Maestro 8.2

Same name and namespace in other branches
  1. 3.x src/Form/MaestroContentTypeCompleteTask.php \Drupal\maestro\Form\MaestroContentTypeCompleteTask::buildForm()

Form constructor.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Return value

array The form structure.

Overrides FormInterface::buildForm

File

src/Form/MaestroContentTypeCompleteTask.php, line 25

Class

MaestroContentTypeCompleteTask
Implements the complete task form for content type tasks when viewing.

Namespace

Drupal\maestro\Form

Code

public function buildForm(array $form, FormStateInterface $form_state, $queueID = NULL) {
  $form = [];
  if ($queueID > 0) {
    $task = MaestroEngine::getTemplateTaskByQueueID($queueID);
    if ($task['tasktype'] == 'MaestroContentType' && MaestroEngine::canUserExecuteTask($queueID, \Drupal::currentUser()
      ->id())) {
      if ($task['tasktype'] == 'MaestroContentType') {
        $form['submit'] = [
          '#type' => 'submit',
          '#value' => isset($task['data']['accept_label']) && $task['data']['accept_label'] != '' ? $this
            ->t($task['data']['accept_label']) : $this
            ->t('Accept'),
        ];

        // Only show the reject button if it has no label.
        if (isset($task['data']['reject_label']) && $task['data']['reject_label'] != '') {
          $form['reject'] = [
            '#type' => 'submit',
            '#value' => isset($task['data']['reject_label']) ? $this
              ->t($task['data']['reject_label']) : $this
              ->t('Reject'),
          ];
        }
        $form['queueid'] = [
          '#type' => 'hidden',
          '#default_value' => $queueID,
        ];
      }
    }
  }
  return $form;
}