class crumbs_ParentFinder in Crumbs, the Breadcrumbs suite 7.2
Same name and namespace in other branches
- 6.2 crumbs.trail.inc \crumbs_ParentFinder
- 7 lib/ParentFinder.php \crumbs_ParentFinder
Can find a parent path for a given path. Contains a cache.
Hierarchy
- class \crumbs_ParentFinder
Expanded class hierarchy of crumbs_ParentFinder
File
- lib/
ParentFinder.php, line 8
View source
class crumbs_ParentFinder {
/**
* @var crumbs_PluginSystem_PluginEngine
*/
protected $pluginEngine;
/**
* @var crumbs_Router;
*/
protected $router;
/**
* @var array
* Cached parent paths
*/
protected $parents = array();
/**
* @param crumbs_PluginSystem_PluginEngine $pluginEngine
* @param crumbs_Router $router
*/
function __construct($pluginEngine, $router) {
$this->pluginEngine = $pluginEngine;
$this->router = $router;
}
/**
* @param string $path
* @param array|null &$item
*
* @return string
*/
function getParentPath($path, &$item) {
if (!isset($this->parents[$path])) {
$parent_path = $this
->_findParentPath($path, $item);
if (is_string($parent_path)) {
$parent_path = $this->router
->getNormalPath($parent_path);
}
$this->parents[$path] = $parent_path;
}
return $this->parents[$path];
}
/**
* @param string $path
* @param array|null &$item
*
* @return string|bool
*/
protected function _findParentPath($path, &$item) {
if ($item) {
if (!$item['access']) {
// Parent should be the front page.
return FALSE;
}
$parent_path = $this->pluginEngine
->findParent($path, $item);
if (isset($parent_path)) {
return $parent_path;
}
}
// fallback: chop off the last fragment of the system path.
$parent_path = $this->router
->reducePath($path);
return isset($parent_path) ? $parent_path : FALSE;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
crumbs_ParentFinder:: |
protected | property | Cached parent paths | |
crumbs_ParentFinder:: |
protected | property | ||
crumbs_ParentFinder:: |
protected | property | ||
crumbs_ParentFinder:: |
function | |||
crumbs_ParentFinder:: |
protected | function | ||
crumbs_ParentFinder:: |
function |