class CourseObjectController in Course 7
Same name and namespace in other branches
- 7.2 includes/CourseObjectController.inc \CourseObjectController
Hierarchy
- class \DrupalDefaultEntityController implements DrupalEntityControllerInterface
- class \EntityAPIController implements EntityAPIControllerRevisionableInterface
- class \CourseObjectController
- class \EntityAPIController implements EntityAPIControllerRevisionableInterface
Expanded class hierarchy of CourseObjectController
1 string reference to 'CourseObjectController'
- course_entity_info in ./
course.module - Implements hook_entity_info().
File
- includes/
CourseObjectController.inc, line 3
View source
class CourseObjectController extends EntityAPIController {
/**
* Overrides EntityAPIController::query().
*/
public function query($ids, $conditions, $revision_id = FALSE) {
$query = $this
->buildQuery($ids, $conditions, $revision_id);
$result = $query
->execute();
$result
->setFetchMode(PDO::FETCH_ASSOC);
// Build the resulting objects ourselves, since the standard PDO ways of
// doing that are completely useless.
$objects = array();
foreach ($result as $row) {
$row['is_new'] = FALSE;
$objects[] = $this
->create($row);
}
return $objects;
}
/**
* Overrides EntityAPIController::create().
*/
public function create(array $values = array()) {
// Add is_new property if it is not set.
$values += array(
'is_new' => TRUE,
);
$available = course_get_handlers('object');
$ret = $available[$values['module']][$values['object_type']];
if ($ret['class']) {
$class = $ret['class'];
}
else {
$class = 'CourseObjectBroken';
}
return new $class($values, $this->entityType);
}
/**
* Fork of Entity API's "merge" functionality.
*
* Merge the serialized field to the entity object.
*/
function load($ids = array(), $conditions = array()) {
$entities = parent::load($ids, $conditions);
$base_table = $this->entityInfo['base table'];
$schema = drupal_get_schema($base_table);
foreach ($schema['fields'] as $field_name => $info) {
if (!empty($info['serialize'])) {
$serialized_field = $field_name;
}
}
foreach ($entities as $courseObject) {
if (isset($courseObject->{$serialized_field}) && is_array($courseObject->{$serialized_field})) {
$reflect = new ReflectionClass($courseObject);
foreach ($reflect
->getProperties(ReflectionProperty::IS_PRIVATE | ReflectionProperty::IS_PROTECTED) as $prop) {
$props[$prop
->getName()] = $prop
->getName();
}
foreach ($courseObject->{$serialized_field} as $field => $value) {
if (!isset($props[$field])) {
$courseObject
->setOption($field, $value);
}
}
unset($courseObject->{$serialized_field});
}
}
return $entities;
}
function buildContent($entity, $view_mode = 'full', $langcode = NULL, $content = array()) {
$build = parent::buildContent($entity, $view_mode, $langcode, $content);
$build['#theme'] = 'course_object';
return $build;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CourseObjectController:: |
function |
Implements EntityAPIControllerInterface. Overrides EntityAPIController:: |
||
CourseObjectController:: |
public | function |
Overrides EntityAPIController::create(). Overrides EntityAPIController:: |
|
CourseObjectController:: |
function |
Fork of Entity API's "merge" functionality. Overrides EntityAPIController:: |
||
CourseObjectController:: |
public | function |
Overrides EntityAPIController::query(). Overrides EntityAPIController:: |
|
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 | 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. | |
EntityAPIController:: |
protected | property | ||
EntityAPIController:: |
protected | property | ||
EntityAPIController:: |
protected | property | ||
EntityAPIController:: |
protected | function |
Overrides DrupalDefaultEntityController::buildQuery(). Overrides DrupalDefaultEntityController:: |
1 |
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:: |
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 |