/** * @param crumbs_InjectedAPI_Collection_PluginCollection $pluginCollection */ 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); } } } } } }
/** * @param crumbs_PluginInterface $plugin * @param string $plugin_key * @param string|null $route * * @throws Exception */ private function addPlugin(crumbs_PluginInterface $plugin, $plugin_key, $route = NULL) { $this->pluginCollection->addPlugin($plugin, $plugin_key, $route); }