【问题标题】:How to decorate the final class DocumentGenerator如何装饰最终类 DocumentGenerator
【发布时间】:2022-08-03 16:49:18
【问题描述】:

我在装饰最终类 \"DocumentGenerator\"(在 vendor/shopware/core/Checkout/Document/Service/DocumentGenerator.php 中)并覆盖其中的 \"generate\" 函数时遇到问题。 我试图用通常的方式装饰它,但是由于\“DocumentController\”类除了原始类而不是我装饰的类而引发错误吗?

传递给 Shopware\\Core\\Checkout\\Document\\DocumentGeneratorController::__construct() 的参数 2 必须是 Shopware\\Core\\Checkout\\Document\\Service\\DocumentGenerator 的实例

它也无法从我的装饰类中扩展,因为 \"DocumentGenerator\" 是最终类。

我的目标是在生成订单文档后执行附加代码。以前我成功地用来装饰 \"DocumentService\" 类,但它被标记为已弃用,不应再使用。 \"DocumentGenerator\" 类也用于新的 \"bulkedit\" 函数,用于从版本 6.4.14.0 开始的文档

我很感激每一个提示。

    标签: shopware shopware6


    【解决方案1】:

    可能不是您想要的,但是:该服务是最终目的,因为它不是为了装饰。

    所以简单的答案是你不能。根据您的用例,可能还有其他不依赖装饰的方式。

    【讨论】:

      猜你喜欢
      • 2010-12-23
      • 2012-07-31
      • 1970-01-01
      • 2019-11-06
      • 2019-02-03
      相关资源
      最近更新 更多