protected function crumbs_PluginSystem_PluginEngine::find in Crumbs, the Breadcrumbs suite 7.2
Invoke all relevant plugins to find title or parent for a given path.
Parameters
crumbs_PluginSystem_PluginMethodIterator $iterator:
array $args: Parameter values to pass to plugin methods.
bool $processFindParent:
Return value
mixed|null
2 calls to crumbs_PluginSystem_PluginEngine::find()
- crumbs_PluginSystem_PluginEngine::findParent in lib/
PluginSystem/ PluginEngine.php - Invoke all relevant plugins to find the parent for a given path.
- crumbs_PluginSystem_PluginEngine::findTitle in lib/
PluginSystem/ PluginEngine.php - Invoke all relevant plugins to find the title for a given path.
File
- lib/
PluginSystem/ PluginEngine.php, line 129
Class
Code
protected function find($iterator, $args, $processFindParent = FALSE) {
$best_candidate = NULL;
$best_candidate_weight = 999999;
$best_candidate_key = NULL;
foreach ($iterator as $plugin_key => $position) {
if (!$position instanceof crumbs_PluginSystem_PluginMethodIteratorPosition) {
continue;
}
if ($position
->isMultiPlugin()) {
$localWeightMap = $this->weightMap
->localWeightMap($plugin_key);
if ($best_candidate_weight <= $localWeightMap
->smallestValue()) {
return $best_candidate;
}
$candidates = $position
->invokeFinderMethod($args);
if (empty($candidates)) {
continue;
}
foreach ($candidates as $candidate_key => $candidate_raw) {
if (!isset($candidate_raw)) {
continue;
}
$candidate_weight = $localWeightMap
->valueAtKey($candidate_key);
if (FALSE === $candidate_weight) {
continue;
}
if ($best_candidate_weight <= $candidate_weight) {
continue;
}
if ($processFindParent) {
$candidate = $this
->processFindParent($candidate_raw);
if (!isset($candidate)) {
continue;
}
}
else {
$candidate = $candidate_raw;
}
$best_candidate = $candidate;
$best_candidate_weight = $candidate_weight;
}
}
elseif ($position
->isMonoPlugin()) {
$candidate_weight = $this->weightMap
->valueAtKey($plugin_key);
if ($best_candidate_weight <= $candidate_weight) {
return $best_candidate;
}
$candidate_raw = $position
->invokeFinderMethod($args);
if (!isset($candidate_raw)) {
continue;
}
$candidate = $processFindParent ? $this
->processFindParent($candidate_raw) : $candidate_raw;
if (isset($candidate)) {
$best_candidate = $candidate;
$best_candidate_weight = $candidate_weight;
}
}
}
return $best_candidate;
}