You are here

public function Bundle::delete in Entity Construction Kit (ECK) 7.2

Same name and namespace in other branches
  1. 7.3 eck.classes.inc \Bundle::delete()

Delete the entity type.

Overrides DBObject::delete

File

./eck.classes.inc, line 621
Classes for all the different objects used in ECK.

Class

Bundle
A bundle database object.

Code

public function delete() {

  // First delete all of the entities of this bundle.
  $query = new EntityFieldQuery();
  $query
    ->entityCondition('entity_type', $this->entity_type, '=')
    ->entityCondition('bundle', $this->name, '=');
  $results = $query
    ->execute();
  if (!empty($results)) {
    $ids = array_keys($results[$this->entity_type]);
    entity_delete_multiple($this->entity_type, $ids);
  }

  // Then we delete the bundle (field_instances).
  field_attach_delete_bundle($this->entity_type, $this->name);
  parent::delete();
  global $_eck_bundles_cache;
  $cache_enabled = isset($_eck_bundles_cache) ? TRUE : FALSE;
  if ($cache_enabled) {
    $_eck_bundles_cache
      ->reset();
  }
  eck_clean_up_request();
}