首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ApiPlatform & Mercure (私人主题)

ApiPlatform & Mercure (私人主题)
EN

Stack Overflow用户
提问于 2020-07-04 14:00:18
回答 1查看 547关注 0票数 0

我的体系结构是基于Symfony 4.4 / ApiPLatform / Mercure /角9的。我通过在我的resources.yaml ApiPlatform conf文件中添加mercure:true来简单地推动Mercure的工作。现在我需要进行隐私更新。因此,对于ApiPlatform,我必须添加参数私有:true。但是API的响应现在是:

自从Mercure 0.10之后,

目标就不再存在了。将更新标记为私有,或者将Mercure组件降级为0.3版

这是我的yaml配置:

代码语言:javascript
复制
resources:
    App\Entity\Order:
        attributes:
            mercure:
                - private: true
                - topics: ['object.getMercureTopics()']

正确的配置应该是什么?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-07-04 14:54:40

事实上,不是像我想的那样在每个选项中计算ExpressionLanguage,只有当配置的选项是字符串时才计算它。因此,如果需要主题(或其他内容)的ExpressionLanguage,解决方案如下:

代码语言:javascript
复制
public function getMercureOptions()
{
    $topic = sprintf(
        '%s/%s',
        self::MERCURE_TOPIC_PREFIX,
        $this->getSomethingFromTheObject()
    );

    return [
        "private" => true,
        "topics" => [$topic]
    ];
}

然后,yaml配置文件应该是:

代码语言:javascript
复制
resources:
    App\Entity\Order:
        attributes:
            mercure: "object.getMercureOptions()"
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62730047

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档