Skip to content

Commit eb65a02

Browse files
committed
Fix PHP notice triggered when an observer is disabled
1 parent e686f71 commit eb65a02

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
All notable changes to this project will be documented in this file.
44

5+
## WIP
6+
7+
* Fix PHP notice triggered when an observer is disabled
8+
59
## [4.0.2] - 2019-02-06
610
[4.0.2]: https://github.com/Smile-SA/magento2-module-debug-toolbar/compare/4.0.1...4.0.2
711

Plugin/Event/Invoker.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
*/
88
namespace Smile\DebugToolbar\Plugin\Event;
99

10+
use Closure;
1011
use Magento\Framework\Event\InvokerInterface as MagentoInvoker;
1112
use Magento\Framework\Event\Observer as MagentoObserver;
1213
use Smile\DebugToolbar\Helper\Observer as HelperObserver;
@@ -37,18 +38,22 @@ public function __construct(HelperObserver $helperObserver)
3738
* Plugin on dispatch.
3839
*
3940
* @param MagentoInvoker $subject
40-
* @param \Closure $closure
41+
* @param Closure $closure
4142
* @param array $configuration
4243
* @param MagentoObserver $observer
4344
* @return mixed
4445
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
4546
*/
4647
public function aroundDispatch(
4748
MagentoInvoker $subject,
48-
\Closure $closure,
49+
Closure $closure,
4950
array $configuration,
5051
MagentoObserver $observer
5152
) {
53+
if (array_key_exists('disabled', $configuration) && $configuration['disabled'] === true) {
54+
return $closure($configuration, $observer);
55+
}
56+
5257
$eventName = $observer->getEvent()->getName();
5358
$observerInstance = $configuration['instance'];
5459
$observerName = array_key_exists('name', $configuration) ? $configuration['name'] : $observerInstance;

0 commit comments

Comments
 (0)