1<?php
2/**
3 * Zend Framework (http://framework.zend.com/)
4 *
5 * @link      http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license   http://framework.zend.com/license/new-bsd New BSD License
8 */
9
10namespace Zend\EventManager;
11
12use Zend\Stdlib\CallbackHandler;
13use Zend\Stdlib\PriorityQueue;
14
15/**
16 * Interface for shared event listener collections
17 */
18interface SharedEventManagerInterface
19{
20    /**
21     * Retrieve all listeners for a given identifier and event
22     *
23     * @param  string|int $id
24     * @param  string|int $event
25     * @return false|PriorityQueue
26     */
27    public function getListeners($id, $event);
28
29    /**
30     * Attach a listener to an event
31     *
32     * @param  string|array $id Identifier(s) for event emitting component(s)
33     * @param  string $event
34     * @param  callable $callback PHP Callback
35     * @param  int $priority Priority at which listener should execute
36     * @return CallbackHandler|array Either CallbackHandler or array of CallbackHandlers
37     */
38    public function attach($id, $event, $callback, $priority = 1);
39
40    /**
41     * Detach a listener from an event offered by a given resource
42     *
43     * @param  string|int $id
44     * @param  CallbackHandler $listener
45     * @return bool Returns true if event and listener found, and unsubscribed; returns false if either event or listener not found
46     */
47    public function detach($id, CallbackHandler $listener);
48
49    /**
50     * Retrieve all registered events for a given resource
51     *
52     * @param  string|int $id
53     * @return array
54     */
55    public function getEvents($id);
56
57    /**
58     * Clear all listeners for a given identifier, optionally for a specific event
59     *
60     * @param  string|int $id
61     * @param  null|string $event
62     * @return bool
63     */
64    public function clearListeners($id, $event = null);
65}
66