From 4be84c493c0c3e49e9f412f8471b0590d354cbe6 Mon Sep 17 00:00:00 2001 From: jake downs Date: Tue, 10 Dec 2019 15:57:40 -0800 Subject: [PATCH] ability to disable event broadcasting via a config option. --- published/config.stub | 7 +++++++ src/LockEvent.php | 10 ++++++++++ 2 files changed, 17 insertions(+) diff --git a/published/config.stub b/published/config.stub index 082e8cc..2ec1dc6 100644 --- a/published/config.stub +++ b/published/config.stub @@ -66,4 +66,11 @@ return [ Sofa\ModelLocking\ModelLocked::class => null, Sofa\ModelLocking\ModelUnlocked::class => null, ], + + /* + |-------------------------------------------------------------------------- + | Enable event broadcasting? + |-------------------------------------------------------------------------- + */ + 'enable_broadcasting' => true, ]; diff --git a/src/LockEvent.php b/src/LockEvent.php index 06a3722..3b4b9bf 100644 --- a/src/LockEvent.php +++ b/src/LockEvent.php @@ -49,4 +49,14 @@ public function broadcastAs() { return config('model_locking.broadcast_as.'.static::class) ?: static::class; } + + /** + * Determine if this event should broadcast. + * + * @return bool + */ + public function broadcastWhen() + { + return config('model_locking.enable_broadcasting'); + } }