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

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Jean Carlo Machado committed May 17, 2014
162 parents e3292c5 + 1dfee57 + 55843e2 + affa379 + a196779 + 3d3d017 + 6fa20e6 + b20a39d + 226510f + 6d779b2 + ae8a2d3 + b2b7d74 + d748fa1 + dab45d1 + cdb0e25 + 55ca933 + 58174bc + 1804746 + 67c0075 + e5983dd + a8b3425 + a2a193a + 33d1c27 + 1d5cfa1 + 460ae0b + c577f06 + db33b2e + fea371a + c93bbae + a4ff530 + cbd4621 + 4b4dffb + 00380d2 + 3895f9f + 6349844 + b6905a7 + b7735a0 + 8312aef + 7be4333 + 8625190 + 4dd38f5 + e02bd81 + 87c797f + 73208bf + 0272cd1 + 1fcbea4 + 197a891 + 5859e98 + d34ef1c + e06dc2f + 4907ff6 + fd0e0ba + 891fbf7 + 83d5b01 + 4579f15 + c86ed1e + 16b8f20 + 83086b6 + a81c8a5 + a85d989 + 55ef06c + a2d63b1 + 8210d1d + 0a08fc0 + 7d37340 + ab0ab2a + b9e0b9b + e1d4bda + e251276 + 161ba87 + f10c77c + 58cc6ef + cecfbb0 + c165fb8 + 1febb29 + 3325e48 + 8b68fab + 43c1b37 + ec52465 + 2904103 + e4d7a5a + be7b13f + f8dd43d + b1b3322 + 93ccc75 + 2d494af + 25e9a69 + 3f70aa8 + 598d6ed + 8161582 + c01dc55 + 98634fe + 0c55546 + 1c83b8f + 815d8cc + 19c90c8 + 5dbf1b9 + 4a927fd + 4a648ec + d0636ac + 840f139 + aafb3ee + 8600965 + b26220b + 860ba0d + 759cd42 + eebf7bc + 6546e0d + 11d36d3 + 4a1db1e + 04eebff + 892dcff + b878b24 + 2db85a1 + 97242e6 + 9ee6b4d + 13fabed + 8fe32d7 + 035474f + 918b5da + 8d65fb0 + 1f16b54 + 282eead + cb64f10 + 491c672 + e10e997 + 93858ca + d41e72e + 9af5add + 309bc00 + 984be73 + be29716 + 41232e8 + 1b6d07e + 8cd4674 + ee1d485 + e5aa383 + fc3991f + ba6e7b6 + 90ecccb + b1db52f + ef24a14 + ae89a5d + 2963b07 + 5174cf5 + ce1dffc + 0c36811 + 486ca02 + f995ad2 + c4edf83 + f7ed875 + 372eb58 + c450aa4 + b5dc21d + 4c23096 + eaee668 + acb0cc0 + 39b294f + 330b204 + e52149f + 946aba8 + e68a45a commit 0bb600c
Show file tree
Hide file tree
Showing 20 changed files with 91 additions and 70 deletions.
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@
"zf2",
"eventmanager"
],
"homepage": "https://github.com/zendframework/zend-event-manager",
"autoload": {
"psr-4": {
"Zend\\EventManager\\": "src/"
}
},
"require": {
"php": ">=5.3.3",
"php": ">=5.3.23",
"zendframework/zend-stdlib": "self.version"
},
"extra": {
"branch-alias": {
"dev-master": "2.2-dev",
"dev-develop": "2.3-dev"
"dev-master": "2.3-dev",
"dev-develop": "2.4-dev"
}
},
"homepage": "https://github.com/zendframework/zend-event-manager",
"autoload-dev": {
"psr-4": {
"ZendTest\\EventManager\\": "test/"
Expand Down
63 changes: 62 additions & 1 deletion src/EventManagerAwareTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,69 @@

namespace Zend\EventManager;

use Traversable;

/**
* A trait for objects that provide events.
*
* If you use this trait in an object, you will probably want to also implement
* EventManagerAwareInterface, which will make it so the default initializer in
* a ZF2 MVC application will automatically inject an instance of the
* EventManager into your object when it is pulled from the ServiceManager.
*
* @see Zend\Mvc\Service\ServiceManagerConfig
*/
trait EventManagerAwareTrait
{
use ProvidesEvents;
/**
* @var EventManagerInterface
*/
protected $events;

/**
* Set the event manager instance used by this context.
*
* For convenience, this method will also set the class name / LSB name as
* identifiers, in addition to any string or array of strings set to the
* $this->eventIdentifier property.
*
* @param EventManagerInterface $events
* @return mixed
*/
public function setEventManager(EventManagerInterface $events)
{
$identifiers = array(__CLASS__, get_class($this));
if (isset($this->eventIdentifier)) {
if ((is_string($this->eventIdentifier))
|| (is_array($this->eventIdentifier))
|| ($this->eventIdentifier instanceof Traversable)
) {
$identifiers = array_unique(array_merge($identifiers, (array) $this->eventIdentifier));
} elseif (is_object($this->eventIdentifier)) {
$identifiers[] = $this->eventIdentifier;
}
// silently ignore invalid eventIdentifier types
}
$events->setIdentifiers($identifiers);
$this->events = $events;
if (method_exists($this, 'attachDefaultListeners')) {
$this->attachDefaultListeners();
}
return $this;
}

/**
* Retrieve the event manager
*
* Lazy-loads an EventManager instance if none registered.
*
* @return EventManagerInterface
*/
public function getEventManager()
{
if (!$this->events instanceof EventManagerInterface) {
$this->setEventManager(new EventManager());
}
return $this->events;
}
}
52 changes: 6 additions & 46 deletions src/ProvidesEvents.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,55 +9,15 @@

namespace Zend\EventManager;

use Traversable;
trigger_error('Zend\EventManager\ProvidesEvents has been deprecated in favor of Zend\EventManager\EventManagerAwareTrait; please update your code', E_USER_DEPRECATED);

/**
* A trait for objects that provide events
* @deprecated Please use EventManagerAwareTrait instead.
*
* This trait exists solely for backwards compatibility in the 2.x branch and
* will likely be removed in 3.x.
*/
trait ProvidesEvents
{
/**
* @var EventManagerInterface
*/
protected $events;

/**
* Set the event manager instance used by this context
*
* @param EventManagerInterface $events
* @return mixed
*/
public function setEventManager(EventManagerInterface $events)
{
$identifiers = array(__CLASS__, get_class($this));
if (isset($this->eventIdentifier)) {
if ((is_string($this->eventIdentifier))
|| (is_array($this->eventIdentifier))
|| ($this->eventIdentifier instanceof Traversable)
) {
$identifiers = array_unique(array_merge($identifiers, (array) $this->eventIdentifier));
} elseif (is_object($this->eventIdentifier)) {
$identifiers[] = $this->eventIdentifier;
}
// silently ignore invalid eventIdentifier types
}
$events->setIdentifiers($identifiers);
$this->events = $events;
return $this;
}

/**
* Retrieve the event manager
*
* Lazy-loads an EventManager instance if none registered.
*
* @return EventManagerInterface
*/
public function getEventManager()
{
if (!$this->events instanceof EventManagerInterface) {
$this->setEventManager(new EventManager());
}
return $this->events;
}
use EventManagerAwareTrait;
}
2 changes: 1 addition & 1 deletion src/SharedEventManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public function detach($id, CallbackHandler $listener)
/**
* Detach a listener aggregate
*
* Listener aggregates accept an SharedEventManagerInterface instance, and call detachShared()
* Listener aggregates accept a SharedEventManagerInterface instance, and call detachShared()
* of all previously attached listeners.
*
* @param SharedListenerAggregateInterface $aggregate
Expand Down
2 changes: 1 addition & 1 deletion src/SharedListenerAggregateInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* Interface for self-registering event listeners.
*
* Classes implementing this interface may be registered by name or instance
* with an SharedEventManager, without an event name. The {@link attach()} method will
* with a SharedEventManager, without an event name. The {@link attach()} method will
* then be called with the current SharedEventManager instance, allowing the class to
* wire up one or more listeners.
*/
Expand Down
2 changes: 1 addition & 1 deletion test/AbstractListenerAggregateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

Expand Down
6 changes: 3 additions & 3 deletions test/EventManagerAwareTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

namespace ZendTest\EventManager;

use \PHPUnit_Framework_TestCase as TestCase;
use \Zend\EventManager\EventManager;
use PHPUnit_Framework_TestCase as TestCase;
use Zend\EventManager\EventManager;

/**
* @requires PHP 5.4
Expand Down
2 changes: 1 addition & 1 deletion test/EventManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

Expand Down
2 changes: 1 addition & 1 deletion test/FilterChainTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

Expand Down
2 changes: 1 addition & 1 deletion test/GlobalEventManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

Expand Down
2 changes: 1 addition & 1 deletion test/ListenerAggregateTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

Expand Down
2 changes: 1 addition & 1 deletion test/StaticEventManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

Expand Down
2 changes: 1 addition & 1 deletion test/StaticIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

Expand Down
2 changes: 1 addition & 1 deletion test/TestAsset/ClassWithEvents.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

Expand Down
2 changes: 1 addition & 1 deletion test/TestAsset/Functor.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

Expand Down
2 changes: 1 addition & 1 deletion test/TestAsset/MockAbstractListenerAggregate.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

Expand Down
2 changes: 1 addition & 1 deletion test/TestAsset/MockAggregate.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

Expand Down
2 changes: 1 addition & 1 deletion test/TestAsset/MockListenerAggregateTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

Expand Down
2 changes: 1 addition & 1 deletion test/TestAsset/SharedMockAggregate.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

Expand Down
2 changes: 1 addition & 1 deletion test/TestAsset/StaticEventsMock.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

Expand Down

0 comments on commit 0bb600c

Please sign in to comment.