{"issue":{"created_at":"2011-11-28T17:42:22Z","state":"open","updated_at":"2011-11-28T17:42:24Z","user":{"gravatar_id":"256406243346b9253f8610fb1d1e05f6","id":1215373,"url":"https://api.github.com/users/importer","avatar_url":"https://secure.gravatar.com/avatar/256406243346b9253f8610fb1d1e05f6?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","login":"importer"},"comments":2,"body":"Betrifft:\n\n/dca/tl_news_comments.php\n/dca/tl_news_archive.php\n/dca/tl_news.php\n\nund den Großteil der Standard-Extensions.\n\nDurch die Initialisierungsstruktur werden in früher geladenen Modulen gesetzte Callbacks gelöscht.\n\n```\n$GLOBALS['TL_DCA']['tl_news'] = array\n(\n  'config' =>\n  (\n    'onload_callback' => array(\n      ...\n    )\n  )\n)\n```\n\nh2. Lösungsvorschläge:\n\n\n\nh2. A) array_merge\n\n\nJede callback-Deklaration muss zwingend vorhanden und nach folgendem Schema aufgebaut sein, selbst wenn das Modul keine Callbacks definiert:\n\n```\n$GLOBALS['TL_DCA']['tl_news'] = array\n(\n  'config' =>\n  (\n\t\n\t'onload_callback' => array_merge(array\n\t(\n\t\t\n\t\t... callbacks ...\n\t\n\t), (array) $GLOBALS['TL_DCA']['tl_news']['config']['onload_callback']),\t\n  \n)\n```\n\nDa diese Variante in allen Extensions zum Einsatz kommen müsste, dürfte sie wenig praktikabel sein. Ich schlage deswegen folgende Lösung vor:\n\n\nh2. B) Hook loadDataContainer\n\n\nÜber einen Hook in Controller:loadDataContainer läßt sich die Reihenfolge, in der die Module durchlaufen werden, beeinflussen:\n\n```\n/**\n* Load a set of DCA files\n */\nprotected function loadDataContainer($strName)\n{\n\t$arrModules = $this->Config->getActiveModules();\n\n\t// HOOK: loadDataContainer\n\tif (isset($GLOBALS['TL_HOOKS']['loadDataContainer']) && is_array($GLOBALS['TL_HOOKS']['loadDataContainer']))\n\t{\n\t\tforeach($GLOBALS['TL_HOOKS']['loadDataContainer'] as $callback)\n\t\t{\n\t\t\t$this->import($callbackr0);\n\t\t\t$arrModules = $this->$callbackr0->$callbackr1($strName, $arrModules);\n\t\t}\n\t}\n\t\n\tforeach ($arrModules as $strModule)\n\t{\n\t\t$strFile = sprintf('%s/system/modules/%s/dca/%s.php', TL_ROOT, $strModule, $strName);\n\n\t\tif (file_exists($strFile))\n\t\t{\n\t\t\tinclude_once($strFile);\n\t\t}\n\t}\n\n\tinclude(TL_ROOT . '/system/config/dcaconfig.php');\n}\n```\n\nh2. C) ArrayObject\n\n\nEventuell läßt sich $GLOBALS als ArrayObject-Objekt erzeugen und das Überschreiben von Callback-Indizes auf diese Weise vermeiden. Ob dies in dieser Art umsetzbar ist, muss erst noch festgestellt werden.\n\n--- _Originally created by ciss on August 14th, 2009, at 01:15am (ID 948)_","assignee":{"gravatar_id":"87d2e5aefadcb310f9155df28c2b3582","id":1192057,"url":"https://api.github.com/users/leofeyer","avatar_url":"https://secure.gravatar.com/avatar/87d2e5aefadcb310f9155df28c2b3582?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","login":"leofeyer"},"labels":[{"name":"Defect","color":"bd2c00","url":"https://api.github.com/repos/contao/test/labels/Defect"},{"name":"Invalid","color":"ffdd00","url":"https://api.github.com/repos/contao/test/labels/Invalid"},{"name":"news","color":"e6e6e6","url":"https://api.github.com/repos/contao/test/labels/news"}],"id":2370936,"pull_request":{"patch_url":null,"html_url":null,"diff_url":null},"number":948,"title":"onload_callback wird überschrieben","closed_at":null,"html_url":"https://github.com/contao/test/issues/948","url":"https://api.github.com/repos/contao/test/issues/948","milestone":null},"action":"created","comment":{"created_at":"2011-11-28T17:42:23Z","updated_at":"2011-11-28T17:42:23Z","user":{"gravatar_id":"87d2e5aefadcb310f9155df28c2b3582","id":1192057,"url":"https://api.github.com/users/leofeyer","avatar_url":"https://secure.gravatar.com/avatar/87d2e5aefadcb310f9155df28c2b3582?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","login":"leofeyer"},"body":"Eine Änderung im DCA ist logischerweise erst möglich, nachdem es intitialisiert wurde. Du kannst nicht die News/Blog-Erweiterung ändern, wenn diese noch gar nicht geladen ist.\n\n--- _Originally created on August 20th, 2009, at 08:23pm_","id":2903493,"url":"https://api.github.com/repos/contao/test/issues/comments/2903493"}}