You are here

function _crumbs_get_objects in Crumbs, the Breadcrumbs suite 6

Collect plugin objects

1 call to _crumbs_get_objects()
_crumbs_get_objects_by_method in ./crumbs.module
Collect plugin objects, but sorted/keyed in a special way

File

./crumbs.module, line 117

Code

function _crumbs_get_objects() {
  $sort_order = _crumbs_get_settings();
  $objects = array();
  $objects_enabled = array();
  $modules_enabled = array();
  foreach ($sort_order as $order_key => $enabled) {
    if ($enabled) {
      list($object_key, $sub_key) = explode(':', $order_key, 2);
      list($module, $instance_key) = explode('.', $object_key, 2);
      $objects_enabled[$object_key] = TRUE;
      $modules_enabled[$module] = TRUE;
    }
  }
  foreach (module_list(FALSE, TRUE) as $module) {
    $class = $module . '_class_CrumbsParentFinder';
    if (class_exists($class)) {
      if (method_exists($class, 'construct')) {

        // use the factory method.
        $result = call_user_func(array(
          $class,
          'construct',
        ));
        if (is_object($result)) {
          $objects[$module] = $result;
        }
        else {
          if (is_array($result)) {
            foreach ($result as $key => $object) {
              $objects["{$module}.{$key}"] = $object;
            }
          }
        }
      }
      else {
        $objects[$module] = new $class();
      }
    }
  }
  foreach ($objects as $key => $object) {
    if (!is_object($object)) {
      unset($objects[$key]);
    }
  }
  return $objects;
}