function crumbs_PluginEngine::__construct in Crumbs, the Breadcrumbs suite 7
Same name and namespace in other branches
- 6.2 crumbs.plugin_engine.inc \crumbs_PluginEngine::__construct()
File
- lib/
PluginEngine.php, line 12
Class
Code
function __construct(array $plugins, array $weights) {
$this->plugins = $plugins;
foreach ($plugins as $plugin_key => $plugin) {
// $weights[$plugin_key] = FALSE;
}
$this->weightKeeper = new crumbs_RuleWeightKeeper($weights);
foreach ($plugins as $plugin_key => $plugin) {
$keeper = $this->weightKeeper
->prefixedWeightKeeper($plugin_key);
$w_find = $keeper
->getSmallestWeight();
if ($w_find !== FALSE) {
$this->pluginOrder_find[$plugin_key] = $w_find;
}
$w_alter = $keeper
->findWeight();
if ($w_alter !== FALSE) {
$this->pluginOrder_alter[$plugin_key] = $w_alter;
}
}
// lowest weight first = highest priority first
asort($this->pluginOrder_find);
// lowest weight last = highest priority last
arsort($this->pluginOrder_alter);
foreach ($this->pluginOrder_find as $plugin_key => $weight) {
$this->pluginOrder_find[$plugin_key] = $plugins[$plugin_key];
}
foreach ($this->pluginOrder_alter as $plugin_key => $weight) {
$this->pluginOrder_alter[$plugin_key] = $plugins[$plugin_key];
}
}