You are here

protected function crumbs_RuleWeightKeeper::_buildPrefixedWeightKeeper in Crumbs, the Breadcrumbs suite 7

Same name and namespace in other branches
  1. 6.2 crumbs.plugin_engine.inc \crumbs_RuleWeightKeeper::_buildPrefixedWeightKeeper()
1 call to crumbs_RuleWeightKeeper::_buildPrefixedWeightKeeper()
crumbs_RuleWeightKeeper::prefixedWeightKeeper in lib/RuleWeightKeeper.php

File

lib/RuleWeightKeeper.php, line 23

Class

crumbs_RuleWeightKeeper

Code

protected function _buildPrefixedWeightKeeper($prefix) {
  $weights = array();
  $k = strlen($prefix);
  $weights[''] = $weights['*'] = $this
    ->_findWildcardWeight($prefix);
  if (isset($this->ruleWeights[$prefix])) {
    $weights[''] = $this->ruleWeights[$prefix];
  }
  if (isset($this->ruleWeights[$prefix . '.*'])) {
    $weights['*'] = $this->ruleWeights[$prefix . '.*'];
  }
  foreach ($this->ruleWeights as $key => $weight) {
    if (strlen($key) > $k && substr($key, 0, $k + 1) === $prefix . '.') {
      $weights[substr($key, $k + 1)] = $weight;
    }
  }
  return new crumbs_RuleWeightKeeper($weights);
}