Skip to content
Permalink
Browse files

Make sure $object implements EventListenerInterface.

  • Loading branch information...
robertpustulka committed May 4, 2015
1 parent 52feab2 commit 62e1e2a2d7c7d21e884df94f5a97e0350e14f7dc
Showing with 3 additions and 2 deletions.
  1. +3 −2 src/Core/ObjectRegistry.php
@@ -14,6 +14,7 @@
*/
namespace Cake\Core;
use Cake\Event\EventListenerInterface;
use RuntimeException;
/**
@@ -277,7 +278,7 @@ public function set($objectName, $object)
{
list(, $name) = pluginSplit($objectName);
$this->unload($objectName);
if (isset($this->_eventManager)) {
if (isset($this->_eventManager) && $object instanceof EventListenerInterface) {
$this->eventManager()->attach($object);
}
$this->_loaded[$name] = $object;
@@ -297,7 +298,7 @@ public function unload($objectName)
return;
}
$object = $this->_loaded[$objectName];
if (isset($this->_eventManager)) {
if (isset($this->_eventManager) && $object instanceof EventListenerInterface) {
$this->eventManager()->off($object);
}
unset($this->_loaded[$objectName]);

0 comments on commit 62e1e2a

Please sign in to comment.
You can’t perform that action at this time.