Permalink
Browse files

Merge branch 'master' of git://github.com/zendframework/zf2

  • Loading branch information...
sgehrig committed Jan 30, 2011
2 parents 4dc9a11 + dea389c commit 08c06c86425183b722fab5fd8712a4b8b6ffa626
Showing with 2,852 additions and 1,121 deletions.
  1. +180 −0 library/Zend/EventManager/Event.php
  2. +11 −13 library/Zend/{SignalSlot/SignalSlot.php → EventManager/EventDispatcher.php}
  3. +348 −0 library/Zend/EventManager/EventManager.php
  4. +36 −0 library/Zend/EventManager/Exception.php
  5. +39 −0 library/Zend/EventManager/Exception/InvalidArgumentException.php
  6. +10 −7 library/Zend/{Stdlib → EventManager}/Filter.php
  7. +118 −0 library/Zend/EventManager/Filter/FilterIterator.php
  8. +141 −0 library/Zend/EventManager/FilterChain.php
  9. +42 −0 library/Zend/EventManager/HandlerAggregate.php
  10. +29 −6 library/Zend/{SignalSlot → EventManager}/ResponseCollection.php
  11. +5 −13 library/Zend/{SignalSlot/StaticSignalSlot.php → EventManager/StaticEventDispatcher.php}
  12. +183 −0 library/Zend/EventManager/StaticEventManager.php
  13. +137 −28 library/Zend/Filter/FilterChain.php
  14. +5 −5 library/Zend/Filter/StringTrim.php
  15. +2 −2 library/Zend/Session/Manager.php
  16. +5 −5 library/Zend/Session/SessionManager.php
  17. +18 −6 library/Zend/Session/ValidatorChain.php
  18. +0 −164 library/Zend/SignalSlot/GlobalSignals.php
  19. +0 −179 library/Zend/SignalSlot/Signals.php
  20. +76 −50 library/Zend/Stdlib/{SignalHandler.php → CallbackHandler.php}
  21. +5 −2 library/Zend/Stdlib/{ → Exception}/InvalidCallbackException.php
  22. +0 −123 library/Zend/Stdlib/FilterChain.php
  23. +305 −0 library/Zend/Stdlib/PriorityQueue.php
  24. +36 −13 library/Zend/Stdlib/SplPriorityQueue.php
  25. +9 −13 library/Zend/Stdlib/SplQueue.php
  26. +9 −13 library/Zend/Stdlib/SplStack.php
  27. +1 −1 library/Zend/View/PhpRenderer.php
  28. +317 −0 tests/Zend/EventManager/EventManagerTest.php
  29. +154 −0 tests/Zend/EventManager/FilterChainTest.php
  30. +159 −0 tests/Zend/EventManager/StaticEventManagerTest.php
  31. +100 −0 tests/Zend/EventManager/StaticIntegrationTest.php
  32. +54 −0 tests/Zend/EventManager/TestAsset/ClassWithEvents.php
  33. +52 −0 tests/Zend/EventManager/TestAsset/MockAggregate.php
  34. +84 −28 tests/Zend/Filter/FilterChainTest.php
  35. +1 −11 tests/Zend/Session/ContainerTest.php
  36. +3 −2 tests/Zend/Session/TestAsset/TestManager.php
  37. +0 −129 tests/Zend/SignalSlot/GlobalSignalsTest.php
  38. +0 −151 tests/Zend/SignalSlot/SignalsTest.php
  39. +16 −20 tests/Zend/Stdlib/{SignalHandlerTest.php → CallbackHandlerTest.php}
  40. +0 −126 tests/Zend/Stdlib/FilterChainTest.php
  41. +135 −0 tests/Zend/Stdlib/PriorityQueueTest.php
  42. +20 −4 tests/Zend/Stdlib/SplPriorityQueueTest.php
  43. +7 −7 tests/Zend/View/PhpRendererTest.php
@@ -0,0 +1,180 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category Zend
+ * @package Zend_EventManager
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+
+/**
+ * @namespace
+ */
+namespace Zend\EventManager;
+
+/**
+ * Representation of an event
+ *
+ * Encapsulates the target context and parameters passed, and provides some
+ * behavior for interacting with the event manager.
+ *
+ * @category Zend
+ * @package Zend_EventManager
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+class Event
+{
+ /**
+ * @var string Event name
+ */
+ protected $name;
+
+ /**
+ * @var string|object The event target
+ */
+ protected $target;
+
+ /**
+ * @var array|ArrayAccess The event parameters
+ */
+ protected $params = array();
+
+ /**
+ * @var bool Whether or not to stop propagation
+ */
+ protected $stopPropagation = false;
+
+ /**
+ * Constructor
+ *
+ * Accept a target and its parameters.
+ *
+ * @param string $name Event name
+ * @param string|object $target
+ * @param array|ArrayAccess $params
+ * @return void
+ */
+ public function __construct($name, $target, $params)
+ {
+ $this->name = $name;
+ $this->target = $target;
+ $this->setParams($params);
+ }
+
+ /**
+ * Get event name
+ *
+ * @return string
+ */
+ public function getName()
+ {
+ return $this->name;
+ }
+
+ /**
+ * Get the event target
+ *
+ * This may be either an object, or the name of a static method.
+ *
+ * @return string|object
+ */
+ public function getTarget()
+ {
+ return $this->target;
+ }
+
+ /**
+ * Set parameters
+ *
+ * Overwrites parameters
+ *
+ * @param array|ArrayAccess $params
+ * @return Event
+ */
+ public function setParams($params)
+ {
+ if (!is_array($params) && !$params instanceof \ArrayAccess) {
+ throw new Exception\InvalidArgumentException(sprintf(
+ 'Event parameters must be an array or implement ArrayAccess; received "%s"',
+ (is_object($params) ? get_class($params) : gettype($params))
+ ));
+ }
+
+ $this->params = $params;
+ return $this;
+ }
+
+ /**
+ * Get all parameters
+ *
+ * @return array|ArrayAccess
+ */
+ public function getParams()
+ {
+ return $this->params;
+ }
+
+ /**
+ * Get an individual parameter
+ *
+ * If the parameter does not exist, the $default value will be returned.
+ *
+ * @param string|int $name
+ * @param mixed $default
+ * @return mixed
+ */
+ public function getParam($name, $default = null)
+ {
+ if (!isset($this->params[$name])) {
+ return $default;
+ }
+
+ return $this->params[$name];
+ }
+
+ /**
+ * Set an individual parameter to a value
+ *
+ * @param string|int $name
+ * @param mixed $value
+ * @return Event
+ */
+ public function setParam($name, $value)
+ {
+ $this->params[$name] = $value;
+ return $this;
+ }
+
+ /**
+ * Stop further event propagation
+ *
+ * @param bool $flag
+ * @return void
+ */
+ public function stopPropagation($flag)
+ {
+ $this->stopPropagation = (bool) $flag;
+ }
+
+ /**
+ * Is propagation stopped?
+ *
+ * @return bool
+ */
+ public function propagationIsStopped()
+ {
+ return $this->stopPropagation;
+ }
+}
@@ -13,33 +13,31 @@
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
- * @package Zend_SignalSlot
+ * @package Zend_EventManager
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/**
* @namespace
*/
-namespace Zend\SignalSlot;
-
-use Zend\Stdlib\SignalHandler;
+namespace Zend\EventManager;
/**
* Interface for messengers
*
* @category Zend
- * @package Zend_SignalSlot
+ * @package Zend_EventManager
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
-interface SignalSlot
+interface EventDispatcher
{
- public function emit($signal, $argv = null);
- public function emitUntil($callback, $signal, $argv = null);
- public function connect($signal, $context, $handler = null);
- public function detach(SignalHandler $handle);
- public function getSignals();
- public function getHandlers($signal);
- public function clearHandlers($signal);
+ public function emit($event, $context, $argv = array());
+ public function emitUntil($event, $context, $argv, $callback);
+ public function connect($eventOrAggregate, $callback = null, $priority = 1);
+ public function detach($handle);
+ public function getEvents();
+ public function getHandlers($event);
+ public function clearHandlers($event);
}
Oops, something went wrong.

0 comments on commit 08c06c8

Please sign in to comment.