问题描述
限时送ChatGPT账号..我正在尝试使用 TYPO3 和自 TYPO3 v9 以来可用的新 RouteEnhancer 设置类似 REST 的 API.就我而言,我需要通过我的扩展程序设置/扩展站点配置,而不是编辑 config.yaml,因为您不想在安装扩展程序或创建新站点配置后复制一些代码.是否有针对这种情况的最佳实践解决方案?
routeEnhancers:我的扩展插件:类型:Extbase扩展名:MyExtension插件:列表路线:- { routePath: '/api/objects', _controller: 'Api::list', _arguments: {'pageType': '1557996244'} }- { routePath: '/api/objects/{objectUid}', _controller: 'Api::show', _arguments: {'pageType': '1557996244'} }defaultController: 'API::list'默认值:对象标识:'0'要求:objectUid: '\d+'
解决方案 您实际上可以在站点配置中使用导入.这是一个博客扩展示例::>
导入:- { 资源:EXT:blog/Configuration/Routes/Default.yaml"}
因此,您可以将 routeEnhancers
配置放在一个单独的文件中,并在站点配置的顶部使用 imports
来加载和合并它.>
I'm trying to set up an REST like API with TYPO3 and the new RouteEnhancers that are available since TYPO3 v9. For my case I need to setup/extend the Site Configuration through my extension instead of editing the config.yaml because you don't want to copy some code after you installed the extension or created a new Site Configuration. Is there a best practice solution for this case?
routeEnhancers:
MyExtensionlugin:
type: Extbase
extension: MyExtension
plugin: Listing
routes:
- { routePath: '/api/objects', _controller: 'Api::list', _arguments: {'pageType': '1557996244'} }
- { routePath: '/api/objects/{objectUid}', _controller: 'Api::show', _arguments: {'pageType': '1557996244'} }
defaultController: 'Api::list'
defaults:
objectUid: '0'
requirements:
objectUid: '\d+'
解决方案
You can actually use imports in your site configuration. Here's an example from the blog extension:
imports:
- { resource: "EXT:blog/Configuration/Routes/Default.yaml" }
So you can put your routeEnhancers
configuration just like that in a separate file and use imports
on the top of your site configuration to get it loaded and merged.
这篇关于如何在不编辑 config/sites/mysite/config.yaml 的情况下扩展 TYPO3 站点配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
更多推荐
[db:关键词]
发布评论