如何使用Extbase在TYPO3 CMS 6.0上引导插件?

8
我正在尝试在TYPO3 CMS 6.0上通过typoscript使用extbase插件。我使用了以下代码,在网上找到了重复的代码:
10 = USER
10 { 
    userFunc = tx_extbase_core_bootstrap->run
    pluginName = Sermons
    extensionName = VmfdsSermons
    switchableControllerActions {
        Sermon {
            1 = byLatestSeries
            2 = list
            3 = show
    }
}

然而,这只是给我返回了以下错误:
#1289386765: Could not analyse class:Tx_VmfdsSermons_Controller_SermonController maybe not loaded or no autoloader?

我觉得tx_extbase_core_bootstrap->run似乎还没有使用命名空间,因此它试图加载一个名为Tx_VmfdsSermons_Controller_SermonController的类,当它应该调用\TYPO3\VmfdsSermons\Controller\SermonController。有什么方法可以解决这个问题吗?
2个回答

13
你正在寻找属性 vendorName。因此,在你的情况下,应该是这样的:
10 = USER
10 { 
    userFunc      = TYPO3\CMS\Extbase\Core\Bootstrap->run

    pluginName    = Sermons
    extensionName = VmfdsSermons
    vendorName    = TYPO3
    [...]

我还在 ext_localconf.php 文件中使用了 vendor 命名空间:

\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
    '<Vendor>.' . $_EXTKEY, 
    [...]

我使用调试器找到了答案。我从\TYPO3\CMS\Extbase\Mvc\Dispatcher::resolveController()开始,并跳转到TYPO3\CMS\Extbase\Mvc\Request::getControllerObjectName()。有一个成员controllerVendorName,因此我在Extbase中搜索了\TYPO3\CMS\Extbase\Mvc\Request::setControllerVendorName()的setter,精确地只为setControllerVendorName,并在\TYPO3\CMS\Extbase\Mvc\Web\RequestBuilder::build()中找到了匹配项,那里有一个名为vendorName的成员,而在上面的方法\TYPO3\CMS\Extbase\Mvc\Web\RequestBuilder::loadDefaultValues()中就是答案!


7

不应再使用调用tx_extbase_core_bootstrap,因为它在6.0版本中被弃用,并将在7.0中删除。

开发者现在应该使用命名空间来处理所有内容...

您可以使用以下内容:

# bootstrap aufrufen -> run from extbase

userFunc = TYPO3\CMS\Extbase\Core\Bootstrap->run

当然,你是对的,但这并没有解决我的问题。不过,将 vendorName = TYPO3 设置为这样确实解决了问题。 - Christoph Fischer

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接