You are here

function crumbs_InjectedAPI_Collection_EntityPluginCollection::finalize in Crumbs, the Breadcrumbs suite 7.2

Parameters

crumbs_InjectedAPI_Collection_PluginCollection $pluginCollection:

File

lib/InjectedAPI/Collection/EntityPluginCollection.php, line 25

Class

crumbs_InjectedAPI_Collection_EntityPluginCollection

Code

function finalize(crumbs_InjectedAPI_Collection_PluginCollection $pluginCollection) {
  $build = array();
  foreach ($this->entityPlugins as $type => $plugins) {
    foreach ($plugins as $key => $y) {
      list($entity_plugin, $types) = $y;
      if (!isset($types)) {
        foreach ($this->entityRoutes as $route => $x) {
          list($entity_type) = $x;
          $build[$entity_type][$type][$key . '.' . $entity_type] = $entity_plugin;
        }
      }
      elseif (is_array($types)) {
        foreach ($types as $entity_type) {
          $build[$entity_type][$type][$key . '.' . $entity_type] = $entity_plugin;
        }
      }
      elseif (is_string($types)) {
        $entity_type = $types;
        $build[$entity_type][$type][$key] = $entity_plugin;
      }
    }
  }
  foreach ($this->entityRoutes as $route => $x) {
    list($entity_type, $bundle_key, $bundle_name) = $x;
    if (!empty($build[$entity_type])) {
      foreach ($build[$entity_type] as $type => $plugins) {
        foreach ($plugins as $key => $entity_plugin) {
          if ('parent' === $type) {
            $plugin = new crumbs_MultiPlugin_EntityParent($entity_plugin, $entity_type, $bundle_key, $bundle_name);
            $pluginCollection
              ->addPlugin($plugin, $key, $route);
          }
          else {
            $plugin = new crumbs_MultiPlugin_EntityTitle($entity_plugin, $entity_type, $bundle_key, $bundle_name);
            $pluginCollection
              ->addPlugin($plugin, $key, $route);
          }
        }
      }
    }
  }
}