function crumbs_PluginEngine::__construct in Crumbs, the Breadcrumbs suite 6.2
Same name and namespace in other branches
- 7 lib/PluginEngine.php \crumbs_PluginEngine::__construct()
File
- ./
crumbs.plugin_engine.inc, line 168
Class
Code
function __construct(array $plugins, array $weights) {
$this->_plugins = $plugins;
foreach ($plugins as $plugin_key => $plugin) {
if (!method_exists($plugin, 'defineOne')) {
$weights[$plugin_key] = FALSE;
}
if (!method_exists($plugin, 'defineMany') && !method_exists($plugin, 'define')) {
$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];
}
}