From 351c111c40f72847cc834a206628009b042ee1e1 Mon Sep 17 00:00:00 2001 From: Alexandr Date: Wed, 6 Jul 2016 19:06:07 +0300 Subject: [PATCH 1/2] Add detachObserver Adds ability to detach observers --- libraries/joomla/observer/updater.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/libraries/joomla/observer/updater.php b/libraries/joomla/observer/updater.php index f1d8de9529896..f1b9f34fb5c60 100644 --- a/libraries/joomla/observer/updater.php +++ b/libraries/joomla/observer/updater.php @@ -47,7 +47,7 @@ public function __construct(JObservableInterface $observable) /** * Adds an observer to the JObservableInterface instance updated by this - * This method can be called fron JObservableInterface::attachObserver + * This method can be called from JObservableInterface::attachObserver * * @param JObserverInterface $observer The observer object * @@ -60,6 +60,22 @@ public function attachObserver(JObserverInterface $observer) $this->observers[get_class($observer)] = $observer; } + /** + * Removes an observer from the JObservableInterface instance updated by this + * This method can be called from JObservableInterface::attachObserver + * + * @param String $observer The observer class name + * + * @return void + * + * @since 3.6.0 + */ + public function detachObserver($observer) + { + if(isset($this->observers[$observer])) + unset($this->observers[$observer]); + } + /** * Gets the instance of the observer of class $observerClass * From bcda8cb196e30c8e1bfb59e56e7a86bf9e68ba6e Mon Sep 17 00:00:00 2001 From: wojsmol Date: Wed, 6 Jul 2016 19:18:23 +0200 Subject: [PATCH 2/2] Simple CS fix --- libraries/joomla/observer/updater.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libraries/joomla/observer/updater.php b/libraries/joomla/observer/updater.php index f1b9f34fb5c60..41e87bd847308 100644 --- a/libraries/joomla/observer/updater.php +++ b/libraries/joomla/observer/updater.php @@ -72,8 +72,10 @@ public function attachObserver(JObserverInterface $observer) */ public function detachObserver($observer) { - if(isset($this->observers[$observer])) + if (isset($this->observers[$observer])) + { unset($this->observers[$observer]); + } } /**