public function WorkflowStateController::save in Workflow 7.2
Implements EntityAPIControllerInterface.
Parameters
$transaction: Optionally a DatabaseTransaction object to use. Allows overrides to pass in their transaction object.
Overrides EntityAPIController::save
File
- includes/
Entity/ WorkflowState.php, line 562 - Contains workflow\includes\Entity\WorkflowState. Contains workflow\includes\Entity\WorkflowStateController.
Class
Code
public function save($entity, DatabaseTransaction $transaction = NULL) {
// Create the machine_name.
if (empty($entity->name)) {
if ($label = $entity->state) {
$entity->name = str_replace(' ', '_', strtolower($label));
}
else {
$entity->name = 'state_' . $entity->sid;
}
}
$return = parent::save($entity, $transaction);
if ($return) {
$workflow = $entity
->getWorkflow();
// Maintain the new object in the workflow.
$workflow->states[$entity->sid] = $entity;
}
// Reset the cache for the affected workflow.
workflow_reset_cache($entity->wid);
return $return;
}