You are here

class CerPresetController in Corresponding Entity References 7.3

The controller class for CerPreset entities.

Hierarchy

Expanded class hierarchy of CerPresetController

1 string reference to 'CerPresetController'
cer_entity_info in ./cer.module
Implements hook_entity_info().

File

includes/CerPresetController.inc, line 6

View source
class CerPresetController extends EntityAPIControllerExportable {

  /**
   * Overridden.
   */
  public function export($entity, $prefix = '') {
    $variables = get_object_vars($entity);

    // I really wish Entity API tried to notify the entity that it's being
    // exported so that it could clean itself up first, but it doesn't. So we
    // gotta do this bizness.
    unset($variables['pid'], $variables['wrapper'], $variables['status'], $variables['module'], $variables['label_variables'], $variables['uid']);

    // Features 2.x checks for overriddenness using sorted keys, which means
    // that if the variables aren't key-sorted the presets will always be
    // considered overridden, even if they actually aren't.
    ksort($variables);
    return entity_var_json_export($variables, $prefix);
  }

  /**
   * Overridden.
   */
  protected function attachLoad(&$queried_entities, $revision_id = FALSE) {
    parent::attachLoad($queried_entities, $revision_id);
    foreach ($queried_entities as $preset) {

      // Attach variables used to build the human-readable preset label. These
      // need to be attached after the Field API has done its magic (i.e.,
      // during parent::attachLoad()), since the label depends on field values.
      // @see CerPreset::label().
      $fields = field_attach_view('cer', $preset, 'default');
      $preset->label_variables = array(
        '@left' => render($fields['cer_left'][0]),
        '@right' => render($fields['cer_right'][0]),
        '!operator' => $preset->wrapper->cer_bidirectional
          ->value() ? '<>' : '>',
      );
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
CerPresetController::attachLoad protected function Overridden. Overrides EntityAPIControllerExportable::attachLoad
CerPresetController::export public function Overridden. Overrides EntityAPIControllerExportable::export
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.
EntityAPIController::saveRevision protected function Saves an entity revision.
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::delete public function Overridden to care about reverted entities. Overrides EntityAPIController::delete
EntityAPIControllerExportable::invoke public function Overridden to care about reverted bundle entities and to skip Rules. Overrides EntityAPIController::invoke
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