Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Commit

Permalink
Merge branch 'hotfix/geteventmanager' of https://github.com/akrabat/zf2
Browse files Browse the repository at this point in the history
… into feature/eventmanager-getter
  • Loading branch information
Show file tree
Hide file tree
Showing 17 changed files with 31 additions and 31 deletions.
16 changes: 8 additions & 8 deletions src/Storage/Adapter/AbstractAdapter.php
Expand Up @@ -115,7 +115,7 @@ public function __destruct()
}

if ($this->eventHandles) {
$events = $this->events();
$events = $this->getEventManager();
foreach ($this->eventHandles as $handle) {
$events->detach($handle);
}
Expand Down Expand Up @@ -145,7 +145,7 @@ public function setOptions($options)
$this->options = $options;

$event = new Event('option', $this, new ArrayObject($options->toArray()));
$this->events()->trigger($event);
$this->getEventManager()->trigger($event);
}
return $this;
}
Expand Down Expand Up @@ -205,7 +205,7 @@ public function getCaching()
*
* @return EventManagerInterface
*/
public function events()
public function getEventManager()
{
if ($this->events === null) {
$this->events = new EventManager(array(__CLASS__, get_called_class()));
Expand All @@ -222,7 +222,7 @@ public function events()
*/
protected function triggerPre($eventName, ArrayObject $args)
{
return $this->events()->trigger(new Event($eventName . '.pre', $this, $args));
return $this->getEventManager()->trigger(new Event($eventName . '.pre', $this, $args));
}

/**
Expand All @@ -236,7 +236,7 @@ protected function triggerPre($eventName, ArrayObject $args)
protected function triggerPost($eventName, ArrayObject $args, & $result)
{
$postEvent = new PostEvent($eventName . '.post', $this, $args, $result);
$eventRs = $this->events()->trigger($postEvent);
$eventRs = $this->getEventManager()->trigger($postEvent);
if ($eventRs->stopped()) {
return $eventRs->last();
}
Expand All @@ -260,7 +260,7 @@ protected function triggerPost($eventName, ArrayObject $args, & $result)
protected function triggerException($eventName, ArrayObject $args, & $result, \Exception $exception)
{
$exceptionEvent = new ExceptionEvent($eventName . '.exception', $this, $args, $result, $exception);
$eventRs = $this->events()->trigger($exceptionEvent);
$eventRs = $this->getEventManager()->trigger($exceptionEvent);

if ($exceptionEvent->getThrowException()) {
throw $exceptionEvent->getException();
Expand Down Expand Up @@ -303,7 +303,7 @@ public function addPlugin(Plugin\PluginInterface $plugin, $priority = 1)
));
}

$plugin->attach($this->events(), $priority);
$plugin->attach($this->getEventManager(), $priority);
$registry->attach($plugin);

return $this;
Expand All @@ -320,7 +320,7 @@ public function removePlugin(Plugin\PluginInterface $plugin)
{
$registry = $this->getPluginRegistry();
if ($registry->contains($plugin)) {
$plugin->detach($this->events());
$plugin->detach($this->getEventManager());
$registry->detach($plugin);
}
return $this;
Expand Down
2 changes: 1 addition & 1 deletion src/Storage/Adapter/AdapterOptions.php
Expand Up @@ -265,7 +265,7 @@ protected function triggerOptionEvent($optionName, $optionValue)
{
if ($this->adapter instanceof EventsCapableInterface) {
$event = new Event('option', $this->adapter, new ArrayObject(array($optionName => $optionValue)));
$this->adapter->events()->trigger($event);
$this->adapter->getEventManager()->trigger($event);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Storage/Adapter/Apc.php
Expand Up @@ -666,7 +666,7 @@ protected function internalGetCapabilities()
);

// update namespace separator on change option
$this->events()->attach('option', function ($event) use ($capabilities, $marker) {
$this->getEventManager()->attach('option', function ($event) use ($capabilities, $marker) {
$params = $event->getParams();

if (isset($params['namespace_separator'])) {
Expand Down
6 changes: 3 additions & 3 deletions src/Storage/Adapter/Filesystem.php
Expand Up @@ -411,7 +411,7 @@ public function getTotalSpace()
}

// clean total space buffer on change cache_dir
$events = $this->events();
$events = $this->getEventManager();
$handle = null;
$totalSpace = & $this->totalSpace;
$callback = function ($event) use (& $events, & $handle, & $totalSpace) {
Expand All @@ -421,7 +421,7 @@ public function getTotalSpace()
$events->detach($handle);
}
};
$handle = $this->events()->attach($callback);
$handle = $this->getEventManager()->attach($callback);
}
return $this->totalSpace;
}
Expand Down Expand Up @@ -1199,7 +1199,7 @@ protected function internalGetCapabilities()
);

// update capabilities on change options
$this->events()->attach('option', function ($event) use ($capabilities, $marker) {
$this->getEventManager()->attach('option', function ($event) use ($capabilities, $marker) {
$params = $event->getParams();

if (isset($params['namespace_separator'])) {
Expand Down
2 changes: 1 addition & 1 deletion src/Storage/Adapter/Memcached.php
Expand Up @@ -106,7 +106,7 @@ public function __construct($options = null)
// get notified on change options
$memc = $this->memcached;
$memcMV = static::$extMemcachedMajorVersion;
$this->events()->attach('option', function ($event) use ($memc, $memcMV) {
$this->getEventManager()->attach('option', function ($event) use ($memc, $memcMV) {
$params = $event->getParams();

if (isset($params['lib_options'])) {
Expand Down
2 changes: 1 addition & 1 deletion src/Storage/Adapter/WinCache.php
Expand Up @@ -483,7 +483,7 @@ protected function internalGetCapabilities()
);

// update namespace separator on change option
$this->events()->attach('option', function ($event) use ($capabilities, $marker) {
$this->getEventManager()->attach('option', function ($event) use ($capabilities, $marker) {
$params = $event->getParams();

if (isset($params['namespace_separator'])) {
Expand Down
2 changes: 1 addition & 1 deletion src/Storage/Capabilities.php
Expand Up @@ -464,7 +464,7 @@ protected function setCapability(stdClass $marker, $name, $value)

// trigger event
if ($this->storage instanceof EventsCapableInterface) {
$this->storage->events()->trigger('capability', $this->storage, new ArrayObject(array(
$this->storage->getEventManager()->trigger('capability', $this->storage, new ArrayObject(array(
$name => $value
)));
}
Expand Down
2 changes: 1 addition & 1 deletion test/Pattern/CallbackCacheTest.php
Expand Up @@ -122,7 +122,7 @@ public function testGenerateKey()

$generatedKey = $this->_pattern->generateKey($callback, $args);
$usedKey = null;
$this->_options->getStorage()->events()->attach('setItem.pre', function ($event) use (&$usedKey) {
$this->_options->getStorage()->getEventManager()->attach('setItem.pre', function ($event) use (&$usedKey) {
$params = $event->getParams();
$usedKey = $params['key'];
});
Expand Down
2 changes: 1 addition & 1 deletion test/Pattern/ClassCacheTest.php
Expand Up @@ -104,7 +104,7 @@ public function testGenerateKey()

$generatedKey = $this->_pattern->generateKey('emptyMethod', $args);
$usedKey = null;
$this->_options->getStorage()->events()->attach('setItem.pre', function ($event) use (&$usedKey) {
$this->_options->getStorage()->getEventManager()->attach('setItem.pre', function ($event) use (&$usedKey) {
$params = $event->getParams();
$usedKey = $params['key'];
});
Expand Down
2 changes: 1 addition & 1 deletion test/Pattern/ObjectCacheTest.php
Expand Up @@ -118,7 +118,7 @@ public function testGenerateKey()

$generatedKey = $this->_pattern->generateKey('emptyMethod', $args);
$usedKey = null;
$this->_options->getStorage()->events()->attach('setItem.pre', function ($event) use (&$usedKey) {
$this->_options->getStorage()->getEventManager()->attach('setItem.pre', function ($event) use (&$usedKey) {
$params = $event->getParams();
$usedKey = $params['key'];
});
Expand Down
2 changes: 1 addition & 1 deletion test/Storage/Adapter/AbstractAdapterTest.php
Expand Up @@ -728,7 +728,7 @@ protected function checkPreEventCanChangeArguments($method, array $args, array $

// init mock
$this->_storage = $this->getMockForAbstractAdapter(array($internalMethod));
$this->_storage->events()->attach($eventName, function ($event) use ($expectedArgs) {
$this->_storage->getEventManager()->attach($eventName, function ($event) use ($expectedArgs) {
$params = $event->getParams();
foreach ($expectedArgs as $k => $v) {
$params[$k] = $v;
Expand Down
2 changes: 1 addition & 1 deletion test/Storage/CapabilitiesTest.php
Expand Up @@ -92,7 +92,7 @@ public function testGetCapabilityByBaseCapabilities()

public function testTriggerCapabilityEvent()
{
$em = $this->_capabilities->getAdapter()->events();
$em = $this->_capabilities->getAdapter()->getEventManager();
$event = null;
$em->attach('capability', function ($eventArg) use (&$event) {
$event = $eventArg;
Expand Down
4 changes: 2 additions & 2 deletions test/Storage/Plugin/ClearExpiredByFactorTest.php
Expand Up @@ -40,7 +40,7 @@ public function testAddPlugin()
'addItems.post' => 'clearExpiredByFactor',
);
foreach ($expectedListeners as $eventName => $expectedCallbackMethod) {
$listeners = $this->_adapter->events()->getListeners($eventName);
$listeners = $this->_adapter->getEventManager()->getListeners($eventName);

// event should attached only once
$this->assertSame(1, $listeners->count());
Expand All @@ -60,7 +60,7 @@ public function testRemovePlugin()
$this->_adapter->removePlugin($this->_plugin);

// no events should be attached
$this->assertEquals(0, count($this->_adapter->events()->getEvents()));
$this->assertEquals(0, count($this->_adapter->getEventManager()->getEvents()));
}

public function testClearExpiredByFactor()
Expand Down
4 changes: 2 additions & 2 deletions test/Storage/Plugin/ExceptionHandlerTest.php
Expand Up @@ -65,7 +65,7 @@ public function testAddPlugin()
'decrementItems.exception' => 'onException',
);
foreach ($expectedListeners as $eventName => $expectedCallbackMethod) {
$listeners = $this->_adapter->events()->getListeners($eventName);
$listeners = $this->_adapter->getEventManager()->getListeners($eventName);

// event should attached only once
$this->assertSame(1, $listeners->count());
Expand All @@ -85,7 +85,7 @@ public function testRemovePlugin()
$this->_adapter->removePlugin($this->_plugin);

// no events should be attached
$this->assertEquals(0, count($this->_adapter->events()->getEvents()));
$this->assertEquals(0, count($this->_adapter->getEventManager()->getEvents()));
}

public function testOnExceptionCallCallback()
Expand Down
4 changes: 2 additions & 2 deletions test/Storage/Plugin/IgnoreUserAbortTest.php
Expand Up @@ -103,7 +103,7 @@ public function testAddPlugin()
'decrementItems.exception' => 'onAfter',
);
foreach ($expectedListeners as $eventName => $expectedCallbackMethod) {
$listeners = $this->_adapter->events()->getListeners($eventName);
$listeners = $this->_adapter->getEventManager()->getListeners($eventName);

// event should attached only once
$this->assertSame(1, $listeners->count());
Expand All @@ -123,6 +123,6 @@ public function testRemovePlugin()
$this->_adapter->removePlugin($this->_plugin);

// no events should be attached
$this->assertEquals(0, count($this->_adapter->events()->getEvents()));
$this->assertEquals(0, count($this->_adapter->getEventManager()->getEvents()));
}
}
4 changes: 2 additions & 2 deletions test/Storage/Plugin/OptimizeByFactorTest.php
Expand Up @@ -36,7 +36,7 @@ public function testAddPlugin()
'removeItems.post' => 'optimizeByFactor',
);
foreach ($expectedListeners as $eventName => $expectedCallbackMethod) {
$listeners = $this->_adapter->events()->getListeners($eventName);
$listeners = $this->_adapter->getEventManager()->getListeners($eventName);

// event should attached only once
$this->assertSame(1, $listeners->count());
Expand All @@ -56,7 +56,7 @@ public function testRemovePlugin()
$this->_adapter->removePlugin($this->_plugin);

// no events should be attached
$this->assertEquals(0, count($this->_adapter->events()->getEvents()));
$this->assertEquals(0, count($this->_adapter->getEventManager()->getEvents()));
}

public function testOptimizeByFactor()
Expand Down
4 changes: 2 additions & 2 deletions test/Storage/Plugin/SerializerTest.php
Expand Up @@ -77,7 +77,7 @@ public function testAddPlugin()
'getCapabilities.post' => 'onGetCapabilitiesPost',
);
foreach ($expectedListeners as $eventName => $expectedCallbackMethod) {
$listeners = $this->_adapter->events()->getListeners($eventName);
$listeners = $this->_adapter->getEventManager()->getListeners($eventName);

// event should attached only once
$this->assertSame(1, $listeners->count());
Expand Down Expand Up @@ -106,7 +106,7 @@ public function testRemovePlugin()
$this->_adapter->removePlugin($this->_plugin);

// no events should be attached
$this->assertEquals(0, count($this->_adapter->events()->getEvents()));
$this->assertEquals(0, count($this->_adapter->getEventManager()->getEvents()));
}

public function testUnserializeOnReadItem()
Expand Down

0 comments on commit c2a03a9

Please sign in to comment.