class OrganigramsItemController in Organigrams 7
Controller class for organigrams items.
This extends the DrupalDefaultEntityController class. Only alternation is that we match the condition on organigrams item name case-independently.
Hierarchy
- class \DrupalDefaultEntityController implements DrupalEntityControllerInterface
- class \EntityAPIController implements EntityAPIControllerRevisionableInterface
- class \OrganigramsItemController
- class \EntityAPIController implements EntityAPIControllerRevisionableInterface
Expanded class hierarchy of OrganigramsItemController
1 string reference to 'OrganigramsItemController'
- organigrams_entity_info in ./
organigrams.module - Implements hook_entity_info().
File
- ./
organigrams.module, line 2112 - Defines the organigrams functions and entity types.
View source
class OrganigramsItemController extends EntityAPIController {
/**
* Builds the query to load the entity.
*
* @param array $ids
* An array of entity IDs, or FALSE to load all entities.
* @param array $conditions
* An array of conditions in the form 'field' => $value.
* @param mixed $revision_id
* The ID of the revision to load, or FALSE if this query is asking for the
* most current revision(s).
*
* @return SelectQuery
* A SelectQuery object for loading the entity.
*/
protected function buildQuery($ids, $conditions = array(), $revision_id = FALSE) {
$query = parent::buildQuery($ids, $conditions, $revision_id);
$query
->addTag('translatable');
$query
->addTag('organigrams_item_access');
// When name is passed as a condition use LIKE.
if (isset($conditions['name'])) {
$query_conditions =& $query
->conditions();
foreach ($query_conditions as $key => $condition) {
if ($condition['field'] == 'base.name') {
$query_conditions[$key]['operator'] = 'LIKE';
$query_conditions[$key]['value'] = db_like($query_conditions[$key]['value']);
}
}
}
// Add the machine name field from the {organigrams} table.
$query
->innerJoin('organigrams_data', 'o', 'base.oid = o.oid');
$query
->addField('o', 'machine_name', 'organigrams_machine_name');
return $query;
}
/**
* Gets entities from the static cache.
*
* @param array $ids
* An array of entity IDs, or FALSE to load all entities.
* @param array $conditions
* An array of conditions in the form 'field' => $value.
*
* @return array
* Array of entities from the entity cache.
*/
protected function cacheGet($ids, $conditions = array()) {
$organigrams_items = parent::cacheGet($ids, $conditions);
// Name matching is case insensitive, note that with some collations
// LOWER() and drupal_strtolower() may return different results.
foreach ($organigrams_items as $organigrams_item) {
// Convert organigrams item to an array.
$organigrams_item_values = (array) $organigrams_item;
// Remove any mismatching names.
if (isset($conditions['name']) && drupal_strtolower($conditions['name'] != drupal_strtolower($organigrams_item_values['name']))) {
// Remove the organigrams item.
unset($organigrams_items[$organigrams_item->iid]);
}
}
return $organigrams_items;
}
}
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 | 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. | |
EntityAPIController:: |
protected | property | ||
EntityAPIController:: |
protected | property | ||
EntityAPIController:: |
protected | property | ||
EntityAPIController:: |
public | function |
Implements EntityAPIControllerInterface. Overrides EntityAPIControllerInterface:: |
|
EntityAPIController:: |
public | function |
Implements EntityAPIControllerInterface. Overrides EntityAPIControllerInterface:: |
|
EntityAPIController:: |
public | function |
Implements EntityAPIControllerInterface. Overrides EntityAPIControllerInterface:: |
1 |
EntityAPIController:: |
public | function |
Implements EntityAPIControllerRevisionableInterface::deleteRevision(). Overrides EntityAPIControllerRevisionableInterface:: |
|
EntityAPIController:: |
public | function |
Implements EntityAPIControllerInterface. Overrides EntityAPIControllerInterface:: |
1 |
EntityAPIController:: |
public | function |
Implements EntityAPIControllerInterface. Overrides EntityAPIControllerInterface:: |
|
EntityAPIController:: |
public | function |
Implements EntityAPIControllerInterface. Overrides EntityAPIControllerInterface:: |
1 |
EntityAPIController:: |
public | function |
Overridden. Overrides DrupalDefaultEntityController:: |
1 |
EntityAPIController:: |
public | function | Builds and executes the query for loading. | |
EntityAPIController:: |
protected | function | Renders a single entity property. | |
EntityAPIController:: |
public | function |
Overrides DrupalDefaultEntityController::resetCache(). Overrides DrupalDefaultEntityController:: |
1 |
EntityAPIController:: |
public | function |
Implements EntityAPIControllerInterface. Overrides EntityAPIControllerInterface:: |
1 |
EntityAPIController:: |
protected | function | Saves an entity revision. | |
EntityAPIController:: |
public | function |
Implements EntityAPIControllerInterface. Overrides EntityAPIControllerInterface:: |
1 |
EntityAPIController:: |
public | function |
Overridden. Overrides DrupalDefaultEntityController:: |
1 |
OrganigramsItemController:: |
protected | function |
Builds the query to load the entity. Overrides EntityAPIController:: |
|
OrganigramsItemController:: |
protected | function |
Gets entities from the static cache. Overrides DrupalDefaultEntityController:: |