public function EntityDefaultUIController::applyOperation

cis7 public EntityDefaultUIController::applyOperation($op, $entity)
cle7 public EntityDefaultUIController::applyOperation($op, $entity)
elmsmedia7 public EntityDefaultUIController::applyOperation($op, $entity)
icor7 public EntityDefaultUIController::applyOperation($op, $entity)
meedjum_blog7 public EntityDefaultUIController::applyOperation($op, $entity)
mooc7 public EntityDefaultUIController::applyOperation($op, $entity)

Applies an operation to the given entity.

Note: the export operation is directly carried out by the operationForm() method.


string $op: The operation (revert, delete or import).

$entity: The entity to manipulate.

Return value

The status message of what has been applied.

1 call to EntityDefaultUIController::applyOperation()
EntityDefaultUIController::operationFormSubmit in sites/all/modules/ulmus/entity/includes/
Operation form submit callback.


sites/all/modules/ulmus/entity/includes/, line 437
Provides a controller for building an entity overview form.


Default UI controller providing admin UI.


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':
      entity_delete($this->entityType, $id);
      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':
      entity_delete($this->entityType, $id);
      watchdog($this->entityType, 'Deleted %entity %label.', $vars);
      return t('Deleted %entity %label.', $vars);

    case 'import':
      // First check if there is any existing entity with the same ID.
      $id = entity_id($this->entityType, $entity);
      $entities = entity_load($this->entityType, array($id));
      if ($existing_entity = reset($entities)) {
        // Copy DB id and remove the new indicator to overwrite the DB record.
        $idkey = $this->entityInfo['entity keys']['id'];
        $entity->{$idkey} = $existing_entity->{$idkey};
      entity_save($this->entityType, $entity);
      watchdog($this->entityType, 'Imported %entity %label.', $vars);
      return t('Imported %entity %label.', $vars);

      return FALSE;