public function EntityDefaultUIController::applyOperation

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

Applies an operation to the given entity.

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

Parameters

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/entity.ui.inc
Operation form submit callback.

File

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

Class

EntityDefaultUIController
Default UI controller providing admin UI.

Code

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};
        unset($entity->is_new);
      }
      entity_save($this->entityType, $entity);
      watchdog($this->entityType, 'Imported %entity %label.', $vars);
      return t('Imported %entity %label.', $vars);

    default:
      return FALSE;
  }
}
Error | ELMSLN API

Error

×

Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/elmsln_community/api.elmsln.org/includes/common.inc:2791) in drupal_send_headers() (line 1499 of /var/www/html/elmsln_community/api.elmsln.org/includes/bootstrap.inc).
  • Error: Call to undefined function apc_delete() in DrupalAPCCache->clear() (line 289 of /var/www/html/elmsln_community/api.elmsln.org/sites/all/modules/apc/drupal_apc_cache.inc).
The website encountered an unexpected error. Please try again later.