You are here

function eck__entity_type__load in Entity Construction Kit (ECK) 7

Load an entity type object @arg $entity_type (String) the name of the entity_type object to load

if no entity_type is given, all the objects are loaded

9 calls to eck__entity_type__load()
eck_entity_info in ./eck.module
Implements hook_entity_info().
eck_entity_property_info_alter in ./eck.module
Implements hook_entity_property_info_alter().
eck_entity_type_features_export_options in ./eck.features.inc
Implementation of hook_features_export_options().
eck_entity_type_features_export_render in ./eck.features.inc
Implementation of hook_features_export_render().
eck_permission in ./eck.module
Implements hook_permission().

... See full list

File

./eck.entity_type.inc, line 64
ENTITY TYPE

Code

function eck__entity_type__load($entity_type_name = NULL) {
  $query = db_select('eck_entity_type', 'e')
    ->fields('e');
  if ($entity_type_name) {
    $query
      ->condition('name', $entity_type_name);
  }
  $data = $query
    ->execute();
  if ($entity_type_name) {
    $entity_type = $data
      ->fetchObject();

    // Why the f*ck did I specify the 'serialize' flag in hook_schema() if it's useless anyway?!
    $entity_type->properties = unserialize($entity_type->properties);
    $entity_type->custom_properties = unserialize($entity_type->custom_properties);
    return $entity_type;
  }
  else {
    $entity_types = array();
    foreach ($data as $entity_type) {
      $entity_type->properties = unserialize($entity_type->properties);
      $entity_type->custom_properties = unserialize($entity_type->custom_properties);
      $entity_types[] = $entity_type;
    }
    return $entity_types;
  }
}