Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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+'
like image 983
Jonas Avatar asked May 16 '19 08:05

Jonas


1 Answers

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.

like image 195
Mathias Brodala Avatar answered Oct 11 '22 11:10

Mathias Brodala