private function addChildTablesToBackendModules($parentTables)
{
$localMenu = array_replace_recursive($GLOBALS['BE_MOD'], $this->backendMenu);
$lastCount = count($parentTables);
// Loop until all tables are injected or until there was no injection during one run.
// This is important, as we might have models that are child of another model.
while ($parentTables) {
foreach ($parentTables as $parentTable => $childTables) {
foreach ($localMenu as $groupName => $modules) {
foreach ($modules as $moduleName => $moduleConfiguration) {
if (isset($moduleConfiguration['tables']) && in_array($parentTable, $moduleConfiguration['tables'])) {
// First put them into our private list.
$this->backendMenu[$groupName][$moduleName]['tables'] = array_merge($localMenu[$groupName][$moduleName]['tables'], $childTables);
// And now buffer them in the backend menu copy to be able to resolve.
$localMenu[$groupName][$moduleName]['tables'] = array_merge($localMenu[$groupName][$moduleName]['tables'], $this->backendMenu[$groupName][$moduleName]['tables']);
unset($parentTables[$parentTable]);
break;
}
}
}
}
// If the dependencies can not be resolved any further, we give up here.
if (count($parentTables) == $lastCount) {
break;
}
$lastCount = count($parentTables);
}
}