How to extend TYPO3 Site Configuration without editing config/sites/mysite/config.yaml

為{幸葍}努か 提交于 2020-08-22 06:09:26

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!