【发布时间】:2013-07-29 12:13:38
【问题描述】:
我使用域模型 Message 创建了一个扩展。该模型与 TYPO3 pages(具有页面详细信息,如标题、issite_root 等)表的关系为 m:n。但是,通过使用mapping to existing tables 选项,它给了我type 错误提示页面:
The configured type field for table "pages" is of type int(11) unsigned
This means the type field can not be used for defining the record type.
You have to configure the mappings yourself if you want to map to this
table or extend the correlated class
所以我只创建没有映射的关系,以便以后可以从setup.txt 映射它。
我在MyExt/Classes/Domain/Model/ 中创建了模型Pages,所有的getter/setter 和存储库都在MyExt/Classes/Domain/Repository/ 中。
在我的 setup.txt 中我这样做了:
config.tx_extbase {
persistence{
enableAutomaticCacheClearing = 1
updateReferenceIndex = 0
classes {
Tx_Playfield_Domain_Model_Pages {
mapping {
tableName = pages
columns {
uid.mapOnProperty = uid
pid.mapOnProperty = pid
sorting.mapOnProperty = sorting
title.mapOnProperty = title
subtitle.mapOnProperty = subtitle
}
}
}
}
}
}
但是当我尝试访问我创建的 Pages 模型时,
var_dump($this->pagesRepository->findByUid(74));
它搜索不存在的tx_playfield_domain_model_pages,它显示
Table 'typo3.tx_playfield_domain_model_pages' doesn't exist: SELECT tx_playfield_domain_model_pages.* FROM tx_playfield_domain_model_pages WHERE tx_playfield_domain_model_pages.uid = '74' LIMIT 1
我在这里错过了什么?
更新
在关注@Michael 建议的http://t3-developer.com/extbase-fluid/cheats-extbase/model/tabelle-pages-in-extbase/ 后,我从$this->pagesRepository->findByUid(74) 得到empty result
setup.txt 正在加载。我这样做是为了检查它:
plugin.tx_playfield{
settings{
temp=yes
}
}
这是从我的控制器访问的。
【问题讨论】:
-
setup.txt 对我来说看起来不错。您的模型在 MyExt/Classes/Domain/Model/Pages.php 中是如何定义的?您是否检查过 setup.txt 是否在运行时实际加载(使用 TS 对象浏览器stackoverflow.com/a/6671818/283854)?您是否尝试使用
config.tx_playfield而不是config.tx_extbase设置相同的内容? -
是的。我更新了,似乎 setup.txt 已加载,但是 extbase 不知道它的映射。我也试过
config.tx_playfield,但它不起作用! -
顺便说一句:最好使用
\TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump($var, 'Name');进行调试。它有很多优点。 -
在扩展 pw_teaser (source code) 中有一个页面/tt_content 的有效 Extbase 实现。