You are here

public function EntityWorkflowUIController::applyOperation in Workflow 7.2

Overrides the 'revert' action, to not delete the workflows.

Overrides EntityDefaultUIController::applyOperation

See also

https://www.drupal.org/node/2051079

https://www.drupal.org/node/1043634

File

workflow_admin_ui/includes/Entity/EntityWorkflowUIController.php, line 149
Contains workflow_admin_ui\includes\Entity\EntityWorkflowUIController.

Class

EntityWorkflowUIController
@file Contains workflow_admin_ui\includes\Entity\EntityWorkflowUIController.

Code

public function applyOperation($op, $entity) {
  $admin_path = $this->path;
  $label = entity_label($this->entityType, $entity);
  $vars = array(
    '%entity' => $this->entityInfo['label'],
    '%label' => $label,
  );
  $wid = entity_id($this->entityType, $entity);
  $edit_link = l(t('edit'), "{$admin_path}/manage/{$wid}/edit");
  switch ($op) {
    case 'revert':
      $defaults = workflow_get_defaults($entity->module);
      workflow_revert($defaults, $entity
        ->getName());
      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);
  }
}