Back to WorkflowBehaviorTrait class

Method workflowAfterSave

public void
workflowAfterSave
(mixed $data)
Executing of relevant workflow methods
Returns
  • void
Since
  • 4.0.0

Method workflowAfterSave - Source code

/**
 * Executing of relevant workflow methods
 *
 * @return  void
 *
 * @since   4.0.0
 */
public function workflowAfterSave($data)
{
    // Regardless if workflow is active or not, we have to set the default stage
    // So we can work with the workflow, when the user activates it later
    $id = $this->getState($this->getName() . '.id');
    $isNew = $this->getState($this->getName() . '.new');
    // We save the first stage
    if ($isNew) {
        // We have to add the paths, because it could be called outside of the extension context
        $path = JPATH_BASE . '/components/' . $this->extension;
        $path = Path::check($path);
        Form::addFormPath($path . '/forms');
        Form::addFormPath($path . '/models/forms');
        Form::addFieldPath($path . '/models/fields');
        Form::addFormPath($path . '/model/form');
        Form::addFieldPath($path . '/model/field');
        $form = $this->getForm();
        $stage_id = $this->getStageForNewItem($form, $data);
        $this->workflow->createAssociation($id, $stage_id);
    }
    if (!$this->workflowEnabled) {
        return;
    }
    // Execute transition
    if (!empty($data['transition'])) {
        $this->executeTransition([$id], $data['transition']);
    }
}