public function Workflow::save in Workflow 7.2
Same name and namespace in other branches
- 7 includes/Entity/Workflow.php \Workflow::save()
Given information, update or insert a new workflow.
This also handles importing, rebuilding, reverting from Features, as defined in workflow.features.inc.
When changing this function, test with the following situations:
- maintain Workflow in Admin UI;
- clone Workflow in Admin UI;
- create/revert/rebuild Workflow with Features; - save Workflow programmatically;
Overrides Entity::save
See also
File
- includes/
Entity/ Workflow.php, line 54 - Contains workflow\includes\Entity\Workflow. Contains workflow\includes\Entity\WorkflowController.
Class
Code
public function save($create_creation_state = TRUE) {
// Are we saving a new Workflow?
$is_new = !empty($this->is_new);
// Are we rebuilding, reverting a new Workflow? @see workflow.features.inc
$is_rebuild = !empty($this->is_rebuild) || !empty($this->is_reverted);
if ($is_rebuild) {
$this->is_rebuild = TRUE;
$this
->preRebuild();
}
$return = parent::save();
// On either clone or rebuild from features.
if ($is_new || $is_rebuild) {
$this
->rebuildInternals();
if ($is_rebuild) {
// The above may have marked us overridden!
$this->status = ENTITY_IN_CODE;
parent::save();
}
}
// Make sure a Creation state exists.
if ($is_new) {
$state = $this
->getCreationState();
}
workflow_reset_cache($this->wid);
return $return;
}