从 TYPO3 6.1 中的 Extbase 映射到“页面”表

2023-11-27

我使用域模型创建了一个扩展Message。该模型与 TYPO3 具有 m:n 关系pages(包含页面详细信息的表,如标题、issite_root 等)表。然而,通过使用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.

enter image description here

我创建的模型Pages in MyExt/Classes/Domain/Model/所有 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

我在这里缺少什么?

Update

关注后http://t3-developer.com/extbase-fluid/cheats-extbase/model/tabelle-pages-in-extbase/由@Michael建议我得到一个empty result from $this->pagesRepository->findByUid(74)

setup.txt正在加载。我这样做是为了检查它:

plugin.tx_playfield{
settings{
 temp=yes
}
}

这是从我的控制器访问的。


是否有可能是您没有创建Pages域模型(在扩展构建器内或根本不在扩展构建器内)?文件my_ext/Classes/Domain/Model/Pages.php需要存在。检查您的“Pages”域模型是否具有该属性映射到现有表 set to pages,它应该看起来像这样:

enter image description here

我不知道你的错误到底在哪里,但我在扩展构建器中做了一些修改并使其工作。您可能可以通过比较您的扩展来找出答案操场到我的临时分机测试场: 在这里下载(已更新).


顺便说一句,您不需要映射不想在前端显示的属性,除非它们的名称不同。

        mapping {
            tableName = pages
            columns {
                title.mapOnProperty = title
                subtitle.mapOnProperty = subtitle
            }
        }
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

从 TYPO3 6.1 中的 Extbase 映射到“页面”表 的相关文章

  • 相关模型的每个实例的活动管理范围

    我对动态活动管理范围有疑问 我试图为我的应用程序中 项目 的每个 经理 创建一个范围 但是 当创建新的经理 或分配给项目 时 范围似乎不会更新 但如果我重新启动服务器 它们会更新 所以代码本身 有效 但显然不是按照我希望的方式 我是一个 r

随机推荐