EventInterface.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. /**
  3. * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
  4. * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  5. *
  6. * Licensed under The MIT License
  7. * For full copyright and license information, please see the LICENSE.txt
  8. * Redistributions of files must retain the above copyright notice.
  9. *
  10. * @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  11. * @link http://cakephp.org CakePHP(tm) Project
  12. * @since 3.3.2
  13. * @license http://www.opensource.org/licenses/mit-license.php MIT License
  14. */
  15. namespace Cake\Event;
  16. /**
  17. * Represents the transport interface for events across the system.
  18. */
  19. interface EventInterface
  20. {
  21. /**
  22. * Access the event data/payload.
  23. *
  24. * @param string|null $key The string identifier for the data payload, or if null all of the payload is returned.
  25. * @return array|null The data payload if $key is null, or the data value for the given $key. If the $key does not
  26. * exist a null value should be returned.
  27. */
  28. public function data($key = null);
  29. /**
  30. * Check if the event is stopped
  31. *
  32. * @return bool True if the event is stopped
  33. */
  34. public function isStopped();
  35. /**
  36. * Returns the name of this event. This is usually used as the event identifier
  37. *
  38. * @return string
  39. */
  40. public function name();
  41. /**
  42. * The result value of the event listeners
  43. *
  44. * @return mixed
  45. */
  46. public function result();
  47. /**
  48. * Modify the event data/payload.
  49. *
  50. * @param array|string $key The string identifier to be modified, or an array to replace the payload.
  51. * @param mixed $value The payload value to be modified if $key is a string, otherwise ignored.
  52. * @return $this
  53. */
  54. public function setData($key, $value = null);
  55. /**
  56. * Assigns a result value for the event listener. If a result has already be assigned it will be overwritten.
  57. *
  58. * @param mixed $value
  59. * @return $this
  60. */
  61. public function setResult($value = null);
  62. /**
  63. * Stops the event from being used anymore
  64. *
  65. * @return void
  66. */
  67. public function stopPropagation();
  68. /**
  69. * Returns the subject of this event
  70. *
  71. * @return object
  72. */
  73. public function subject();
  74. }