You are here

protected function crumbs_PluginSystem_PluginInfo::get_pluginOrder in Crumbs, the Breadcrumbs suite 7.2

Order of plugins, for 'find' and 'alter' operations.

Return value

array Format: $['find'][$pluginKey] = $weight.

See also

crumbs_PluginSystem_PluginInfo::$pluginOrder

File

lib/PluginSystem/PluginInfo.php, line 388

Class

crumbs_PluginSystem_PluginInfo
Info about available plugins and their weights.

Code

protected function get_pluginOrder() {
  $order = array(
    'find' => array(),
    'alter' => array(),
  );

  // Sort the plugins, using the weights from weight map.
  $weightMap = $this->weightMap;
  foreach ($this->plugins as $plugin_key => $plugin) {
    if ($plugin instanceof crumbs_MultiPlugin) {
      $localWeightMap = $weightMap
        ->localWeightMap($plugin_key);
      $w_find = $localWeightMap
        ->smallestValue();
      if ($w_find !== FALSE) {
        $order['find'][$plugin_key] = $w_find;
      }

      // Multi plugins cannot participate in alter operations.
    }
    else {
      $weight = $weightMap
        ->valueAtKey($plugin_key);
      if ($weight !== FALSE) {
        $order['find'][$plugin_key] = $weight;
        $order['alter'][$plugin_key] = $weight;
      }
    }
  }

  // Lowest weight first = highest priority first
  asort($order['find']);

  // Lowest weight last = highest priority last
  arsort($order['alter']);
  return $order;
}