You are here

public static function Bundle::loadAll in Entity Construction Kit (ECK) 7.2

Same name and namespace in other branches
  1. 7.3 eck.classes.inc \Bundle::loadAll()

Load all bundles.

Parameters

bool $reset: Retrive from cache if availabe or not.

Return value

array An array of Bundles.

5 calls to Bundle::loadAll()
Bundle::loadByEntityType in ./eck.classes.inc
Load the bundles of an entity type.
Bundle::loadByMachineName in ./eck.classes.inc
This method returns a bundle object.
eck_bundle_features_export_options in ./eck.features.inc
Implements hook_features_export_options().
eck_bundle_features_rebuild in ./eck.features.inc
Implements hook_features_rebuild().
eck_flush_caches in ./eck.module
Implements hook_flush_caches().

File

./eck.classes.inc, line 678
Classes for all the different objects used in ECK.

Class

Bundle
A bundle database object.

Code

public static function loadAll($reset = FALSE) {
  $bundles = array();
  global $_eck_bundles_cache;
  $cache_enabled = isset($_eck_bundles_cache) ? TRUE : FALSE;
  if ($cache_enabled) {
    if ($reset) {
      $_eck_bundles_cache
        ->reset();
    }
    $bundles = $_eck_bundles_cache
      ->get();
  }
  if (empty($bundles)) {
    $bundles = array();

    // @todo move this to a general function.
    $results = db_select('eck_bundle', 't')
      ->fields('t', array(
      'machine_name',
    ))
      ->execute();
    foreach ($results as $result) {
      $name = $result->machine_name;
      $bundle = new Bundle();
      $bundle
        ->load('machine_name', $name);
      $bundles[$name] = $bundle;
    }
    if ($cache_enabled) {
      $_eck_bundles_cache
        ->set($bundles);
    }
  }
  return $bundles;
}