You are here

class BeanEntityAPIController in Bean (for Drupal 7) 7

Hierarchy

Expanded class hierarchy of BeanEntityAPIController

1 string reference to 'BeanEntityAPIController'
bean_entity_info in ./bean.module
Implements hook_entity_info().

File

includes/bean.core.inc, line 452
Bean classes and plugin interface

View source
class BeanEntityAPIController extends EntityAPIControllerExportable {
  protected function setPlugin(Bean $bean) {
    static $plugins = array();
    if (empty($plugins[$bean->type])) {
      $plugins[$bean->type] = bean_load_plugin_class($bean->type);
      $bean
        ->loadUp($plugins[$bean->type]);
    }
  }
  protected function attachLoad(&$queried_entities, $revision_id = FALSE) {
    foreach ($queried_entities as $entity) {
      $this
        ->setPlugin($entity);
    }
    parent::attachLoad($queried_entities, $revision_id);
  }
  public function delete($ids, DatabaseTransaction $transaction = NULL) {
    $beans = $ids ? $this
      ->load($ids) : array();
    $deltas = array();
    foreach ($beans as $bean) {
      if ($bean
        ->internalIdentifier()) {
        field_attach_delete('bean', $bean);
        $deltas[] = $bean
          ->identifier();
      }
    }
    if (!empty($deltas)) {
      try {

        // @see block_custom_block_delete_submit()
        if (module_exists('block')) {
          db_delete('block')
            ->condition('module', 'bean')
            ->condition('delta', $deltas)
            ->execute();
          db_delete('block_role')
            ->condition('module', 'bean')
            ->condition('delta', $deltas)
            ->execute();

          // @see node_form_block_custom_block_delete_submit()
          db_delete('block_node_type')
            ->condition('module', 'bean')
            ->condition('delta', $deltas)
            ->execute();
        }
      } catch (Exception $e) {
        if (isset($transaction)) {
          $transaction
            ->rollback();
        }
        watchdog_exception('bean', $e);
        throw $e;
      }
    }
    parent::delete($ids, $transaction);
  }

  /**
   * Overridden to add Rules integration back in.
   */
  public function invoke($hook, $entity) {
    parent::invoke($hook, $entity);

    // Invoke rules.
    if (module_exists('rules')) {
      rules_invoke_event($this->entityType . '_' . $hook, $entity);
    }
  }
  protected function saveRevision($entity) {
    global $user;
    $org_uid = $entity->uid;
    $entity->uid = $user->uid;
    $return = parent::saveRevision($entity);
    $entity->uid = $org_uid;
    return $return;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
BeanEntityAPIController::attachLoad protected function Overridden. Overrides EntityAPIControllerExportable::attachLoad
BeanEntityAPIController::delete public function Overridden to care about reverted entities. Overrides EntityAPIControllerExportable::delete
BeanEntityAPIController::invoke public function Overridden to add Rules integration back in. Overrides EntityAPIControllerExportable::invoke
BeanEntityAPIController::saveRevision protected function Saves an entity revision. Overrides EntityAPIController::saveRevision
BeanEntityAPIController::setPlugin protected function
DrupalDefaultEntityController::$cache protected property Whether this entity type should use the static cache.
DrupalDefaultEntityController::$entityCache protected property Static cache of entities, keyed by entity ID.
DrupalDefaultEntityController::$entityInfo protected property Array of information about the entity.
DrupalDefaultEntityController::$entityType protected property Entity type for this controller instance.
DrupalDefaultEntityController::$hookLoadArguments protected property Additional arguments to pass to hook_TYPE_load().
DrupalDefaultEntityController::$idKey protected property Name of the entity's ID field in the entity database table.
DrupalDefaultEntityController::$revisionKey protected property Name of entity's revision database table field, if it supports revisions.
DrupalDefaultEntityController::$revisionTable protected property The table that stores revisions, if the entity supports revisions.
DrupalDefaultEntityController::cleanIds protected function Ensures integer entity IDs are valid.
DrupalDefaultEntityController::filterId protected function Callback for array_filter that removes non-integer IDs.
EntityAPIController::$bundleKey protected property
EntityAPIController::$cacheComplete protected property
EntityAPIController::$defaultRevisionKey protected property
EntityAPIController::buildContent public function Implements EntityAPIControllerInterface. Overrides EntityAPIControllerInterface::buildContent
EntityAPIController::create public function Implements EntityAPIControllerInterface. Overrides EntityAPIControllerInterface::create
EntityAPIController::deleteRevision public function Implements EntityAPIControllerRevisionableInterface::deleteRevision(). Overrides EntityAPIControllerRevisionableInterface::deleteRevision
EntityAPIController::import public function Implements EntityAPIControllerInterface. Overrides EntityAPIControllerInterface::import
EntityAPIController::query public function Builds and executes the query for loading.
EntityAPIController::renderEntityProperty protected function Renders a single entity property.
EntityAPIControllerExportable::$entityCacheByName protected property
EntityAPIControllerExportable::$nameKey protected property
EntityAPIControllerExportable::applyConditions protected function
EntityAPIControllerExportable::buildQuery protected function Support loading by name key. Overrides EntityAPIController::buildQuery
EntityAPIControllerExportable::cacheGet protected function Overridden. Overrides DrupalDefaultEntityController::cacheGet
EntityAPIControllerExportable::cacheGetByName protected function Like cacheGet() but keyed by name.
EntityAPIControllerExportable::cacheSet protected function Overridden. Overrides DrupalDefaultEntityController::cacheSet
EntityAPIControllerExportable::export public function Overridden. Overrides EntityAPIController::export
EntityAPIControllerExportable::load public function Overridden to support passing numeric ids as well as names as $ids. Overrides EntityAPIController::load
EntityAPIControllerExportable::resetCache public function Overrides DrupalDefaultEntityController::resetCache(). Overrides EntityAPIController::resetCache
EntityAPIControllerExportable::save public function Overridden to care exportables that are overridden. Overrides EntityAPIController::save
EntityAPIControllerExportable::view public function Implements EntityAPIControllerInterface. Overrides EntityAPIController::view
EntityAPIControllerExportable::__construct public function Overridden. Overrides EntityAPIController::__construct