You are here

public function MaestroContentTypeTask::prepareTaskForSave in Maestro 8.2

Same name and namespace in other branches
  1. 3.x src/Plugin/EngineTasks/MaestroContentTypeTask.php \Drupal\maestro\Plugin\EngineTasks\MaestroContentTypeTask::prepareTaskForSave()

The specific task's manipulation of the values to save for a template save.

Parameters

array $form: The form.

\Drupal\Core\Form\FormStateInterface $form_state: The form's form state.

array $task: The fully loaded task array from the template.

Overrides MaestroEngineTaskInterface::prepareTaskForSave

File

src/Plugin/EngineTasks/MaestroContentTypeTask.php, line 241

Class

MaestroContentTypeTask
Maestro Content Type Task Plugin.

Namespace

Drupal\maestro\Plugin\EngineTasks

Code

public function prepareTaskForSave(array &$form, FormStateInterface $form_state, array &$task) {
  $task['data']['unique_id'] = $form_state
    ->getValue('unique_id');
  $task['data']['content_type'] = $form_state
    ->getValue('content_type');
  $task['data']['save_edit_later'] = $form_state
    ->getValue('save_edit_later');
  $task['data']['link_to_edit'] = $form_state
    ->getValue('link_to_edit');
  $task['data']['show_maestro_buttons_on_view'] = $form_state
    ->getValue('show_maestro_buttons_on_view');
  $task['data']['accept_label'] = $form_state
    ->getValue('accept_label');
  $task['data']['reject_label'] = $form_state
    ->getValue('reject_label');
  $task['data']['accept_redirect_to'] = $form_state
    ->getValue('accept_redirect_to');
  $task['data']['reject_redirect_to'] = $form_state
    ->getValue('reject_redirect_to');
  $task['data']['supply_maestro_ids_in_url'] = $form_state
    ->getValue('supply_maestro_ids_in_url');
  $redirect = $form_state
    ->getValue('redirect_to');
  if (isset($redirect)) {
    $task['data']['redirect_to'] = $redirect;
  }
  else {
    $task['data']['redirect_to'] = '';
  }

  // We create our own handler here based on the content type and signify that it is maestro based
  // This is the NODE ADD handler.  We alter this in a post-assignment hook if the entity identifier already exists in maestro.module
  // see maestro_maestro_post_production_assignments.
  $task['handler'] = '/node/add/' . $form_state
    ->getValue('content_type') . '?maestro=1';
}