EventCollection.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_EventManager
  17. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  18. * @license http://framework.zend.com/license/new-bsd New BSD License
  19. */
  20. require_once 'Zend/Stdlib/CallbackHandler.php';
  21. /**
  22. * Interface for messengers
  23. *
  24. * @category Zend
  25. * @package Zend_EventManager
  26. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  27. * @license http://framework.zend.com/license/new-bsd New BSD License
  28. */
  29. interface Zend_EventManager_EventCollection
  30. {
  31. /**
  32. * Trigger an event
  33. *
  34. * Should allow handling the following scenarios:
  35. * - Passing Event object only
  36. * - Passing event name and Event object only
  37. * - Passing event name, target, and Event object
  38. * - Passing event name, target, and array|ArrayAccess of arguments
  39. *
  40. * Can emulate triggerUntil() if the last argument provided is a callback.
  41. *
  42. * @param string $event
  43. * @param object|string $target
  44. * @param array|object $argv
  45. * @param null|callback $callback
  46. * @return Zend_EventManager_ResponseCollection
  47. */
  48. public function trigger($event, $target = null, $argv = array(), $callback = null);
  49. /**
  50. * Trigger an event until the given callback returns a boolean false
  51. *
  52. * Should allow handling the following scenarios:
  53. * - Passing Event object and callback only
  54. * - Passing event name, Event object, and callback only
  55. * - Passing event name, target, Event object, and callback
  56. * - Passing event name, target, array|ArrayAccess of arguments, and callback
  57. *
  58. * @param string $event
  59. * @param object|string $target
  60. * @param array|object $argv
  61. * @param callback $callback
  62. * @return Zend_EventManager_ResponseCollection
  63. */
  64. public function triggerUntil($event, $target, $argv = null, $callback = null);
  65. /**
  66. * Attach a listener to an event
  67. *
  68. * @param string $event
  69. * @param callback $callback
  70. * @param int $priority Priority at which to register listener
  71. * @return Zend_Stdlib_CallbackHandler
  72. */
  73. public function attach($event, $callback = null, $priority = 1);
  74. /**
  75. * Detach an event listener
  76. *
  77. * @param Zend_Stdlib_CallbackHandler|Zend_EventManager_ListenerAggregate $listener
  78. * @return void
  79. */
  80. public function detach($listener);
  81. /**
  82. * Get a list of events for which this collection has listeners
  83. *
  84. * @return array
  85. */
  86. public function getEvents();
  87. /**
  88. * Retrieve a list of listeners registered to a given event
  89. *
  90. * @param string $event
  91. * @return array|object
  92. */
  93. public function getListeners($event);
  94. /**
  95. * Clear all listeners for a given event
  96. *
  97. * @param string $event
  98. * @return void
  99. */
  100. public function clearListeners($event);
  101. }