You are here

function path_breadcrumbs_load_by_path in Path Breadcrumbs 7.3

Same name and namespace in other branches
  1. 7 path_breadcrumbs.module \path_breadcrumbs_load_by_path()
  2. 7.2 path_breadcrumbs.module \path_breadcrumbs_load_by_path()

Load enabled path_breadcrumbs by path.

Parameters

string $path: Current page path.

Return value

array Array of path_breadcrumbs sorted by weight.

1 call to path_breadcrumbs_load_by_path()
path_breadcrumbs_load_variant in ./path_breadcrumbs.module
Load and build path breadcrumb variant for page url. Results are cached.

File

./path_breadcrumbs.module, line 680

Code

function path_breadcrumbs_load_by_path($path) {
  $data =& drupal_static(__FUNCTION__);
  $pattern_needle = path_breadcrumbs_path_pattern($path);
  if (empty($data[$pattern_needle])) {
    $cache = cache_get(__FUNCTION__, PATH_BREADCRUMBS_CACHE_STORAGE);

    // Ensure the cache object has data.
    if (isset($cache->data)) {
      $data = $cache->data;
    }
    else {

      // Do heavy work and cache results.
      ctools_include('export');

      // No need to sort variants by weight because path_breadcrumbs_load_all()
      // already sorted all data.
      $result = path_breadcrumbs_load_all();
      foreach ($result as $path_breadcrumbs) {
        if (empty($path_breadcrumbs->disabled)) {
          $pattern = path_breadcrumbs_path_pattern($path_breadcrumbs->path);
          $data[$pattern][] = $path_breadcrumbs;
        }
      }
      cache_set(__FUNCTION__, $data, PATH_BREADCRUMBS_CACHE_STORAGE);
    }
  }
  return isset($data[$pattern_needle]) ? $data[$pattern_needle] : array();
}