Skip to content

Commit

Permalink
Make event manager injectable.
Browse files Browse the repository at this point in the history
  • Loading branch information
ADmad committed Dec 6, 2017
1 parent e80815c commit c2f5d41
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/Form/Form.php
Expand Up @@ -83,11 +83,17 @@ class Form implements EventListenerInterface, EventDispatcherInterface, Validato

/**
* Constructor
*
* @param \Cake\Event\EventManager|null $eventManager The event manager.
* Defaults to a new instance.
*/
public function __construct()
public function __construct(EventManager $eventManager = null)
{
$this->_eventManager = new EventManager();
$this->_eventManager->on($this);
if ($eventManager !== null) {
$this->setEventManager($eventManager);
}

$this->getEventManager()->on($this);
}

/**
Expand Down

0 comments on commit c2f5d41

Please sign in to comment.