Skip to content

Commit 0977566

Browse files
committed
Fixed missing flash messages in adminhtml area when layout collector is enabled
1 parent 5b79511 commit 0977566

File tree

2 files changed

+29
-4
lines changed

2 files changed

+29
-4
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
namespace ClawRock\Debug\Plugin;
5+
6+
use Magento\Framework\View\LayoutInterface;
7+
8+
class PreventMessageBlockInitByToolbarPlugin
9+
{
10+
/**
11+
* @param \Magento\Framework\View\LayoutInterface $subject
12+
* @param callable $proceed
13+
* @param array|string $messageGroups
14+
* @return void
15+
*/
16+
public function aroundInitMessages(LayoutInterface $subject, callable $proceed, $messageGroups = [])
17+
{
18+
$handles = $subject->getUpdate()->getHandles();
19+
if ($handles === ['clawrock_debug']) {
20+
// Block is initialized by layout collector, messages can't be initialized
21+
// because there will be no messages during block rendering
22+
return;
23+
}
24+
25+
$proceed($messageGroups);
26+
}
27+
}

etc/adminhtml/di.xml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
<?xml version="1.0"?>
22
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
3-
<type name="ClawRock\Debug\Block\Profiler\Toolbar">
4-
<arguments>
5-
<argument name="url" xsi:type="object">Magento\Framework\Url</argument>
6-
</arguments>
3+
<type name="Magento\Framework\View\Layout">
4+
<plugin name="ClawRock_Debug::prevent_message_block_init_by_toolbar" type="ClawRock\Debug\Plugin\PreventMessageBlockInitByToolbarPlugin"/>
75
</type>
86
</config>

0 commit comments

Comments
 (0)