public function delete($ids, DatabaseTransaction $transaction = NULL) { // @todo: replace WorkflowController::delete() with parent. // @todo: throw error if not workflow->isDeletable(). foreach ($ids as $wid) { if ($workflow = workflow_load($wid)) { $workflow->delete(); } } $this->resetCache(); }
/** * Overrides the 'revert' action, to not delete the workflows. * * @see https://www.drupal.org/node/2051079 * @see https://www.drupal.org/node/1043634 */ public function applyOperation($op, $entity) { $label = entity_label($this->entityType, $entity); $vars = array('%entity' => $this->entityInfo['label'], '%label' => $label); $id = entity_id($this->entityType, $entity); $edit_link = l(t('edit'), $this->path . '/manage/' . $id . '/edit'); switch ($op) { case 'revert': // Do not delete the workflow, but recreate features_get_default($entity_type, $module); // entity_delete($this->entityType, $id); $workflow = $entity; $entity_type = $this->entityType; $funcname = $workflow->module . '_default_' . $this->entityType; $defaults = $funcname(); // No defaults, no processing. if (empty($defaults)) { return; } foreach ($defaults as $name => $entity) { $existing[$name] = workflow_load($name); // If we got an existing entity with the same name, we reuse its entity id. if (isset($existing[$name])) { // Set the original as later reference. $entity->original = $existing[$name]; // As we got an ID, the entity is not new. $entity->wid = $entity->original->wid; unset($entity->is_new); // Update the status to be in code. // $entity->status |= ENTITY_IN_CODE; $entity->status = ENTITY_IN_CODE; // We mark it for being in revert mode. $entity->is_reverted = TRUE; entity_save($entity_type, $entity); unset($entity->is_reverted); } // The rest of the defaults is handled by default implementation. // @see entity_defaults_rebuild() } watchdog($this->entityType, 'Reverted %entity %label to the defaults.', $vars, WATCHDOG_NOTICE, $edit_link); return t('Reverted %entity %label to the defaults.', $vars); case 'delete': case 'import': default: return parent::applyOperation($op, $entity); } }
/** * Get the Transitions $workflow. * * @return Workflow|NULL * The workflow for this Transition. */ public function getWorkflow() { $workflow = NULL; if (!$this->wid) { $state = workflow_state_load_single($this->new_sid ? $this->new_sid : $this->old_sid); $this->wid = (int) $state->wid; } if ($this->wid) { $workflow = workflow_load($this->wid); } return $workflow; }
/** * Get the Transitions $workflow. * * @return object * The workflow for this Transition. */ public function getWorkflow() { $state = workflow_state_load_single($this->new_sid); $workflow = workflow_load($state->wid); return $workflow; }