如何在不编辑 config/sites/mysite/config.yaml 的情况下扩展 TYPO3 站点配置

编程入门 行业动态 更新时间:2024-10-26 22:19:49
本文介绍了如何在不编辑 config/sites/mysite/config.yaml 的情况下扩展 TYPO3 站点配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送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:关键词]

本文发布于:2023-04-29 09:06:52,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1187556.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:情况下   编辑   站点   如何在   mysite

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!