Back to AdminController class

Method runTransition

public bool
runTransition
()
Method to run Transition by id of item.
Returns
  • bool Indicates whether the transition was successful.
Since
  • 4.0.0

Method runTransition - Source code

/**
 * Method to run Transition by id of item.
 *
 * @return  boolean  Indicates whether the transition was successful.
 *
 * @since   4.0.0
 */
public function runTransition()
{
    // Check for request forgeries
    $this->checkToken();
    // Get the input
    $pks = (array) $this->input->post->get('cid', array(), 'int');
    // Remove zero values resulting from input filter
    $pks = array_filter($pks);
    if (!\count($pks)) {
        return false;
    }
    $transitionId = (int) $this->input->post->getInt('transition_id');
    // Get the model
    $model = $this->getModel();
    if (!$model instanceof WorkflowModelInterface) {
        return false;
    }
    $return = $model->executeTransition($pks, $transitionId);
    $redirect = Route::_('index.php?option=' . $this->option . '&view=' . $this->view_list . $this->getRedirectToListAppend(), false);
    if ($return === false) {
        // Transition change failed.
        $message = Text::sprintf('JLIB_APPLICATION_ERROR_RUN_TRANSITION', $model->getError());
        $this->setRedirect($redirect, $message, 'error');
        return false;
    }
    // Transition change succeeded.
    $message = Text::_('JLIB_APPLICATION_SUCCESS_RUN_TRANSITION');
    $this->setRedirect($redirect, $message);
    return true;
}