class EntityBlockController in Entity Blocks 7
The controller class for Entity Block.
Hierarchy
- class \DrupalDefaultEntityController implements DrupalEntityControllerInterface
- class \EntityBlockController implements EntityBlockControllerInterface
Expanded class hierarchy of EntityBlockController
1 string reference to 'EntityBlockController'
- entity_block_entity_info in ./
entity_block.module - Implements hook_entity_info().
File
- ./
entity_block.controller.inc, line 40 - The controller for the EntityBlock entity.
View source
class EntityBlockController extends DrupalDefaultEntityController implements EntityBlockControllerInterface {
/**
* Create and return a new entity_block entity.
*/
public function create() {
$entity = new stdClass();
$entity->type = 'entity_block';
$entity->bundle = 'entity_block';
$entity->title = '';
$entity->entity_block_id = 0;
$entity->target_entity_type = 'node';
$entity->target_bundle = '';
$entity->target_view_mode = '';
$entity->target_entity_id = '';
return $entity;
}
/**
* Saves the entity.
*/
public function save($entity) {
// Invoke hook_entity_presave().
module_invoke_all('entity_presave', $entity, 'entity_block');
// Get the primary key.
$primary_keys = $entity->entity_block_id ? 'entity_block_id' : array();
// Save the entity.
drupal_write_record('entity_block', $entity, $primary_keys);
// Callback hooks.
$invocation = 'entity_insert';
if (empty($primary_keys)) {
field_attach_insert('entity_block', $entity);
}
else {
field_attach_update('entity_block', $entity);
$invocation = 'entity_update';
}
module_invoke_all($invocation, $entity, 'entity_block');
return $entity;
}
/**
* Deletes an entity_block.
*/
public function delete($entity) {
$this
->deleteMultiple(array(
$entity,
));
}
/**
* Deletes multiple entity_blocks.
*
* @param array $entities
* An array of entity IDs or a single numeric ID.
* @throws \Exception
*/
public function deleteMultiple($entities) {
$entity_block_ids = array();
if (!empty($entities)) {
$transaction = db_transaction();
try {
foreach ($entities as $entity) {
// Invoke hook_entity_delete().
module_invoke_all('entity_delete', $entity, 'entity_block');
field_attach_delete('entity_block', $entity);
$entity_block_ids[] = $entity->entity_block_id;
}
db_delete('entity_block')
->condition('entity_block_id', $entity_block_ids, 'IN')
->execute();
} catch (Exception $e) {
$transaction
->rollback();
watchdog_exception('entity_block', $e);
throw $e;
}
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DrupalDefaultEntityController:: |
protected | property | Whether this entity type should use the static cache. | |
DrupalDefaultEntityController:: |
protected | property | Static cache of entities, keyed by entity ID. | |
DrupalDefaultEntityController:: |
protected | property | Array of information about the entity. | |
DrupalDefaultEntityController:: |
protected | property | Entity type for this controller instance. | |
DrupalDefaultEntityController:: |
protected | property | Additional arguments to pass to hook_TYPE_load(). | |
DrupalDefaultEntityController:: |
protected | property | Name of the entity's ID field in the entity database table. | |
DrupalDefaultEntityController:: |
protected | property | Name of entity's revision database table field, if it supports revisions. | |
DrupalDefaultEntityController:: |
protected | property | The table that stores revisions, if the entity supports revisions. | |
DrupalDefaultEntityController:: |
protected | function | Attaches data to entities upon loading. | 4 |
DrupalDefaultEntityController:: |
protected | function | Builds the query to load the entity. | 4 |
DrupalDefaultEntityController:: |
protected | function | Gets entities from the static cache. | 1 |
DrupalDefaultEntityController:: |
protected | function | Stores entities in the static entity cache. | |
DrupalDefaultEntityController:: |
protected | function | Ensures integer entity IDs are valid. | |
DrupalDefaultEntityController:: |
protected | function | Callback for array_filter that removes non-integer IDs. | |
DrupalDefaultEntityController:: |
public | function |
Implements DrupalEntityControllerInterface::load(). Overrides DrupalEntityControllerInterface:: |
|
DrupalDefaultEntityController:: |
public | function |
Implements DrupalEntityControllerInterface::resetCache(). Overrides DrupalEntityControllerInterface:: |
|
DrupalDefaultEntityController:: |
public | function | Constructor: sets basic variables. | |
EntityBlockController:: |
public | function |
Create and return a new entity_block entity. Overrides EntityBlockControllerInterface:: |
|
EntityBlockController:: |
public | function |
Deletes an entity_block. Overrides EntityBlockControllerInterface:: |
|
EntityBlockController:: |
public | function | Deletes multiple entity_blocks. | |
EntityBlockController:: |
public | function |
Saves the entity. Overrides EntityBlockControllerInterface:: |