From 6e6fffa4613b9dcbc26762c76f64d29abc71d001 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sun, 3 May 2020 21:44:45 +0100 Subject: [PATCH] Inventory: added removeAllListeners() this isn't strictly necessary because it could be done by removeListeners(...getListeners()), but I think developers will appreciate not needing so much boilerplate code. --- src/inventory/BaseInventory.php | 4 ++++ src/inventory/Inventory.php | 2 ++ 2 files changed, 6 insertions(+) diff --git a/src/inventory/BaseInventory.php b/src/inventory/BaseInventory.php index dcf620bfd..63ecb4d8f 100644 --- a/src/inventory/BaseInventory.php +++ b/src/inventory/BaseInventory.php @@ -384,6 +384,10 @@ abstract class BaseInventory implements Inventory{ } } + public function removeAllListeners() : void{ + $this->listeners = []; + } + public function getListeners() : array{ return $this->listeners; } diff --git a/src/inventory/Inventory.php b/src/inventory/Inventory.php index 17be0db27..95ea5001a 100644 --- a/src/inventory/Inventory.php +++ b/src/inventory/Inventory.php @@ -164,6 +164,8 @@ interface Inventory{ */ public function removeListeners(InventoryListener ...$listeners) : void; + public function removeAllListeners() : void; + /** * @return InventoryListener[] */