在magento2的发货版本中,有一个 afterDispatch 前控制器上的插件

#File: vendor/magento/module-page-cache/Model/App/FrontController/MessageBox.php
public function afterDispatch(FrontController $subject, $result)
{
    if ($this->request->isPost() && $this->messageManager->hasMessages()) {
        $publicCookieMetadata = $this->cookieMetadataFactory->createPublicCookieMetadata()
            ->setDuration(self::COOKIE_PERIOD)
            ->setPath('/')
            ->setHttpOnly(false);
        $this->cookieManager->setPublicCookie(self::COOKIE_NAME, 1, $publicCookieMetadata);
    }
    return $result;
}

该方法似乎设置了一个 空的 命名的cookie message_box_display.只有当请求是post并且global-via-dependency-injection消息管理器中有任何消息时,才会设置此cookie。

这个"元数据"cookie的目的是什么?我的猜测是它在缓存的页面上触发一个消息框(给定相同的cookie名称在 vendor/magento/module-page-cache/view/frontend/web/js/page-cache.js).然而,鉴于代码调用,这个理论分崩离析 createPublicCookieMetadata 没有参数(意味着"元数据cookie"没有数据)。

我的假设不正确吗?有谁知道这个cookie在更大的框架中的用途?

有帮助吗?

解决方案

评论中的Per@antonkril,

是正确的,这个标志只是为了显示/隐藏。但现在似乎可以删除它,在用新的用户数据方法重建消息呈现之后。我会将此转发给负责团队

听起来像(?)消息呈现已更改,不再需要此插件。

许可以下: CC-BY-SA归因
scroll top