public function MaestroBatchFunctionTask::batchFunctionHandlerCallback in Maestro 8.2
Same name and namespace in other branches
- 3.x src/Plugin/EngineTasks/MaestroBatchFunctionTask.php \Drupal\maestro\Plugin\EngineTasks\MaestroBatchFunctionTask::batchFunctionHandlerCallback()
Implements callback for Ajax event on objective selection.
Parameters
array $form: From render array.
\Drupal\Core\Form\FormStateInterface $form_state: Current state of form.
Return value
array Objective selection section of the form.
File
- src/
Plugin/ EngineTasks/ MaestroBatchFunctionTask.php, line 197
Class
- MaestroBatchFunctionTask
- Maestro Batch Function Task Plugin.
Namespace
Drupal\maestro\Plugin\EngineTasksCode
public function batchFunctionHandlerCallback(array &$form, FormStateInterface $form_state) {
$selected_handler = $new_objective_id = $form_state
->getValue('handler');
// Let modules signal the handlers they wish to share.
$handlers = \Drupal::moduleHandler()
->invokeAll('maestro_batch_handlers', []);
if ($selected_handler != '' && !function_exists($selected_handler)) {
$handler_desc = \Drupal::translation()
->translate('This handler form function does not exist.');
}
elseif (isset($handlers[$selected_handler])) {
$handler_desc = $handlers[$selected_handler];
}
else {
$handler_desc = \Drupal::translation()
->translate('The batch function name you wish to call.');
}
$form['handler_help_text'] = [
'#type' => 'html_tag',
'#tag' => 'div',
'#value' => $handler_desc,
'#readonly' => TRUE,
'#attributes' => [
'class' => [
'handler-help-message',
],
'id' => [
'handler-ajax-refresh-wrapper',
],
],
];
return $form['handler_help_text'];
}