Back to WorkflowBehaviorTrait class

Method batchWorkflowStage

public mixed
batchWorkflowStage
(int $value, array $pks, array $contexts)
Batch change workflow stage or current.
Parameters
  • int $value The workflow stage ID.
  • array $pks An array of row IDs.
  • array $contexts An array of item contexts.
Returns
  • mixed An array of new IDs on success, boolean false on failure.
Since
  • 4.0.0

Method batchWorkflowStage - Source code

/**
 * Batch change workflow stage or current.
 *
 * @param   integer  $value     The workflow stage ID.
 * @param   array    $pks       An array of row IDs.
 * @param   array    $contexts  An array of item contexts.
 *
 * @return  mixed  An array of new IDs on success, boolean false on failure.
 *
 * @since   4.0.0
 */
public function batchWorkflowStage(int $value, array $pks, array $contexts)
{
    $user = Factory::getApplication()->getIdentity();
    $workflow = Factory::getApplication()->bootComponent('com_workflow');
    if (!$user->authorise('core.admin', $this->option)) {
        $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EXECUTE_TRANSITION'));
    }
    // Get workflow stage information
    $stage = $workflow->getMVCFactory()->createTable('Stage', 'Administrator');
    if (empty($value) || !$stage->load($value)) {
        Factory::getApplication()->enqueueMessage(Text::sprintf('JGLOBAL_BATCH_WORKFLOW_STAGE_ROW_NOT_FOUND'), 'error');
        return false;
    }
    if (empty($pks)) {
        Factory::getApplication()->enqueueMessage(Text::sprintf('JGLOBAL_BATCH_WORKFLOW_STAGE_ROW_NOT_FOUND'), 'error');
        return false;
    }
    // Update workflow associations
    return $this->workflow->updateAssociations($pks, $value);
}