问题
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+'
回答1:
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.
来源:https://stackoverflow.com/questions/56164496/how-to-extend-typo3-site-configuration-without-editing-config-sites-mysite-confi