EntityPluginCollection.php in Crumbs, the Breadcrumbs suite 7.2
File
lib/InjectedAPI/Collection/EntityPluginCollection.php
View source
<?php
class crumbs_InjectedAPI_Collection_EntityPluginCollection {
protected $entityRoutes = array();
protected $entityPlugins = array();
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);
}
}
}
}
}
}
function entityRoute($entity_type, $route, $bundle_key, $bundle_name) {
$this->entityRoutes[$route] = array(
$entity_type,
$bundle_key,
$bundle_name,
);
}
function entityPlugin($type, $key, crumbs_EntityPlugin $entity_plugin, $types) {
if ($entity_plugin instanceof crumbs_EntityPlugin) {
$this->entityPlugins[$type][$key] = array(
$entity_plugin,
$types,
);
}
}
}