| author | Nicolas Sauret <nicolas.sauret@iri.centrepompidou.fr> |
| Thu, 16 Apr 2015 13:55:11 +0200 | |
| changeset 1222 | 8f3e355b94b9 |
| parent 808 | 6b6c2214f778 |
| child 1230 | 68c69c656a2c |
| permissions | -rw-r--r-- |
|
808
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
1 |
<?php |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
2 |
/** |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
3 |
* Zend Framework |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
4 |
* |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
5 |
* LICENSE |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
6 |
* |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
7 |
* This source file is subject to the new BSD license that is bundled |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
8 |
* with this package in the file LICENSE.txt. |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
9 |
* It is also available through the world-wide-web at this URL: |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
10 |
* http://framework.zend.com/license/new-bsd |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
11 |
* If you did not receive a copy of the license and are unable to |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
12 |
* obtain it through the world-wide-web, please send an email |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
13 |
* to license@zend.com so we can send you a copy immediately. |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
14 |
* |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
15 |
* @category Zend |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
16 |
* @package Zend_EventManager |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
17 |
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
18 |
* @license http://framework.zend.com/license/new-bsd New BSD License |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
19 |
*/ |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
20 |
|
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
21 |
require_once 'Zend/EventManager/Event.php'; |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
22 |
require_once 'Zend/EventManager/EventCollection.php'; |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
23 |
require_once 'Zend/EventManager/ResponseCollection.php'; |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
24 |
require_once 'Zend/EventManager/SharedEventCollectionAware.php'; |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
25 |
require_once 'Zend/EventManager/StaticEventManager.php'; |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
26 |
require_once 'Zend/Stdlib/CallbackHandler.php'; |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
27 |
require_once 'Zend/Stdlib/PriorityQueue.php'; |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
28 |
|
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
29 |
/** |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
30 |
* Event manager: notification system |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
31 |
* |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
32 |
* Use the EventManager when you want to create a per-instance notification |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
33 |
* system for your objects. |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
34 |
* |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
35 |
* @category Zend |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
36 |
* @package Zend_EventManager |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
37 |
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
38 |
* @license http://framework.zend.com/license/new-bsd New BSD License |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
39 |
*/ |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
40 |
class Zend_EventManager_EventManager implements Zend_EventManager_EventCollection, Zend_EventManager_SharedEventCollectionAware |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
41 |
{ |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
42 |
/** |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
43 |
* Subscribed events and their listeners |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
44 |
* @var array Array of Zend_Stdlib_PriorityQueue objects |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
45 |
*/ |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
46 |
protected $events = array(); |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
47 |
|
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
48 |
/** |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
49 |
* @var string Class representing the event being emitted |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
50 |
*/ |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
51 |
protected $eventClass = 'Zend_EventManager_Event'; |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
52 |
|
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
53 |
/** |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
54 |
* Identifiers, used to pull static signals from StaticEventManager |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
55 |
* @var array |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
56 |
*/ |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
57 |
protected $identifiers = array(); |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
58 |
|
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
59 |
/** |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
60 |
* Static collections |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
61 |
* @var false|null|Zend_EventManager_StaticEventCollection |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
62 |
*/ |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
63 |
protected $sharedCollections = null; |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
64 |
|
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
65 |
/** |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
66 |
* Constructor |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
67 |
* |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
68 |
* Allows optionally specifying identifier(s) to use to pull signals from a |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
69 |
* StaticEventManager. |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
70 |
* |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
71 |
* @param null|string|int|array|Traversable $identifiers |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
72 |
* @return void |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
73 |
*/ |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
74 |
public function __construct($identifiers = null) |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
75 |
{ |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
76 |
$this->setIdentifiers($identifiers); |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
77 |
} |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
78 |
|
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
79 |
/** |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
80 |
* Set the event class to utilize |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
81 |
* |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
82 |
* @param string $class |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
83 |
* @return Zend_EventManager_EventManager |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
84 |
*/ |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
85 |
public function setEventClass($class) |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
86 |
{ |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
87 |
$this->eventClass = $class; |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
88 |
return $this; |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
89 |
} |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
90 |
|
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
91 |
/** |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
92 |
* Set static collections container |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
93 |
* |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
94 |
* @param Zend_EventManager_StaticEventCollection $collections |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
95 |
* @return void |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
96 |
*/ |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
97 |
public function setSharedCollections(Zend_EventManager_SharedEventCollection $collections) |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
98 |
{ |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
99 |
$this->sharedCollections = $collections; |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
100 |
return $this; |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
101 |
} |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
102 |
|
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
103 |
/** |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
104 |
* Remove any shared collections |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
105 |
* |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
106 |
* Sets {@link $sharedCollections} to boolean false to disable ability |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
107 |
* to lazy-load static event manager instance. |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
108 |
* |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
109 |
* @return void |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
110 |
*/ |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
111 |
public function unsetSharedCollections() |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
112 |
{ |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
113 |
$this->sharedCollections = false; |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
114 |
} |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
115 |
|
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
116 |
/** |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
117 |
* Get static collections container |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
118 |
* |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
119 |
* @return false|Zend_EventManager_SharedEventCollection |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
120 |
*/ |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
121 |
public function getSharedCollections() |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
122 |
{ |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
123 |
if (null === $this->sharedCollections) { |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
124 |
$this->setSharedCollections(Zend_EventManager_StaticEventManager::getInstance()); |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
125 |
} |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
126 |
return $this->sharedCollections; |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
127 |
} |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
128 |
|
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
129 |
/** |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
130 |
* Get the identifier(s) for this Zend_EventManager_EventManager |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
131 |
* |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
132 |
* @return array |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
133 |
*/ |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
134 |
public function getIdentifiers() |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
135 |
{ |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
136 |
return $this->identifiers; |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
137 |
} |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
138 |
|
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
139 |
/** |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
140 |
* Set the identifiers (overrides any currently set identifiers) |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
141 |
* |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
142 |
* @param string|int|array|Traversable $identifiers |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
143 |
* @return Zend_EventManager_EventManager |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
144 |
*/ |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
145 |
public function setIdentifiers($identifiers) |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
146 |
{ |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
147 |
if (is_array($identifiers) || $identifiers instanceof Traversable) { |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
148 |
$this->identifiers = array_unique((array) $identifiers); |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
149 |
} elseif ($identifiers !== null) { |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
150 |
$this->identifiers = array($identifiers); |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
151 |
} |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
152 |
return $this; |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
153 |
} |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
154 |
|
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
155 |
/** |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
156 |
* Add some identifier(s) (appends to any currently set identifiers) |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
157 |
* |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
158 |
* @param string|int|array|Traversable $identifiers |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
159 |
* @return Zend_EventManager_EventManager |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
160 |
*/ |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
161 |
public function addIdentifiers($identifiers) |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
162 |
{ |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
163 |
if (is_array($identifiers) || $identifiers instanceof Traversable) { |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
164 |
$this->identifiers = array_unique($this->identifiers + (array) $identifiers); |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
165 |
} elseif ($identifiers !== null) { |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
166 |
$this->identifiers = array_unique(array_merge($this->identifiers, array($identifiers))); |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
167 |
} |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
168 |
return $this; |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
169 |
} |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
170 |
|
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
171 |
/** |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
172 |
* Trigger all listeners for a given event |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
173 |
* |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
174 |
* Can emulate triggerUntil() if the last argument provided is a callback. |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
175 |
* |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
176 |
* @param string $event |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
177 |
* @param string|object $target Object calling emit, or symbol describing target (such as static method name) |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
178 |
* @param array|ArrayAccess $argv Array of arguments; typically, should be associative |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
179 |
* @param null|callback $callback |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
180 |
* @return Zend_EventManager_ResponseCollection All listener return values |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
181 |
*/ |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
182 |
public function trigger($event, $target = null, $argv = array(), $callback = null) |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
183 |
{ |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
184 |
if ($event instanceof Zend_EventManager_EventDescription) { |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
185 |
$e = $event; |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
186 |
$event = $e->getName(); |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
187 |
$callback = $target; |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
188 |
} elseif ($target instanceof Zend_EventManager_EventDescription) { |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
189 |
$e = $target; |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
190 |
$e->setName($event); |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
191 |
$callback = $argv; |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
192 |
} elseif ($argv instanceof Zend_EventManager_EventDescription) { |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
193 |
$e = $argv; |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
194 |
$e->setName($event); |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
195 |
$e->setTarget($target); |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
196 |
} else { |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
197 |
$e = new $this->eventClass(); |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
198 |
$e->setName($event); |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
199 |
$e->setTarget($target); |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
200 |
$e->setParams($argv); |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
201 |
} |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
202 |
|
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
203 |
if ($callback && !is_callable($callback)) { |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
204 |
require_once 'Zend/Stdlib/Exception/InvalidCallbackException.php'; |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
205 |
throw new Zend_Stdlib_Exception_InvalidCallbackException('Invalid callback provided'); |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
206 |
} |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
207 |
|
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
208 |
return $this->triggerListeners($event, $e, $callback); |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
209 |
} |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
210 |
|
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
211 |
/** |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
212 |
* Trigger listeners until return value of one causes a callback to |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
213 |
* evaluate to true |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
214 |
* |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
215 |
* Triggers listeners until the provided callback evaluates the return |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
216 |
* value of one as true, or until all listeners have been executed. |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
217 |
* |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
218 |
* @param string $event |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
219 |
* @param string|object $target Object calling emit, or symbol describing target (such as static method name) |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
220 |
* @param array|ArrayAccess $argv Array of arguments; typically, should be associative |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
221 |
* @param Callable $callback |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
222 |
* @throws Zend_Stdlib_Exception_InvalidCallbackException if invalid callback provided |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
223 |
*/ |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
224 |
public function triggerUntil($event, $target, $argv = null, $callback = null) |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
225 |
{ |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
226 |
if ($event instanceof Zend_EventManager_EventDescription) { |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
227 |
$e = $event; |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
228 |
$event = $e->getName(); |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
229 |
$callback = $target; |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
230 |
} elseif ($target instanceof Zend_EventManager_EventDescription) { |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
231 |
$e = $target; |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
232 |
$e->setName($event); |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
233 |
$callback = $argv; |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
234 |
} elseif ($argv instanceof Zend_EventManager_EventDescription) { |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
235 |
$e = $argv; |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
236 |
$e->setName($event); |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
237 |
$e->setTarget($target); |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
238 |
} else { |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
239 |
$e = new $this->eventClass(); |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
240 |
$e->setName($event); |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
241 |
$e->setTarget($target); |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
242 |
$e->setParams($argv); |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
243 |
} |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
244 |
|
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
245 |
if (!is_callable($callback)) { |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
246 |
require_once 'Zend/Stdlib/Exception/InvalidCallbackException.php'; |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
247 |
throw new Zend_Stdlib_Exception_InvalidCallbackException('Invalid callback provided'); |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
248 |
} |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
249 |
|
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
250 |
return $this->triggerListeners($event, $e, $callback); |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
251 |
} |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
252 |
|
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
253 |
/** |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
254 |
* Attach a listener to an event |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
255 |
* |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
256 |
* The first argument is the event, and the next argument describes a |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
257 |
* callback that will respond to that event. A CallbackHandler instance |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
258 |
* describing the event listener combination will be returned. |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
259 |
* |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
260 |
* The last argument indicates a priority at which the event should be |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
261 |
* executed. By default, this value is 1; however, you may set it for any |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
262 |
* integer value. Higher values have higher priority (i.e., execute first). |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
263 |
* |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
264 |
* You can specify "*" for the event name. In such cases, the listener will |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
265 |
* be triggered for every event. |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
266 |
* |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
267 |
* @param string|array|Zend_EventManager_ListenerAggregate $event An event or array of event names. If a ListenerAggregate, proxies to {@link attachAggregate()}. |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
268 |
* @param callback|int $callback If string $event provided, expects PHP callback; for a ListenerAggregate $event, this will be the priority |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
269 |
* @param int $priority If provided, the priority at which to register the callback |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
270 |
* @return Zend_Stdlib_CallbackHandler|mixed CallbackHandler if attaching callback (to allow later unsubscribe); mixed if attaching aggregate |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
271 |
*/ |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
272 |
public function attach($event, $callback = null, $priority = 1) |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
273 |
{ |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
274 |
// Proxy ListenerAggregate arguments to attachAggregate() |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
275 |
if ($event instanceof Zend_EventManager_ListenerAggregate) { |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
276 |
return $this->attachAggregate($event, $callback); |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
277 |
} |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
278 |
|
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
279 |
// Null callback is invalid |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
280 |
if (null === $callback) { |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
281 |
require_once 'Zend/EventManager/Exception/InvalidArgumentException.php'; |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
282 |
throw new Zend_EventManager_Exception_InvalidArgumentException(sprintf( |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
283 |
'%s: expects a callback; none provided', |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
284 |
__METHOD__ |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
285 |
)); |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
286 |
} |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
287 |
|
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
288 |
// Array of events should be registered individually, and return an array of all listeners |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
289 |
if (is_array($event)) { |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
290 |
$listeners = array(); |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
291 |
foreach ($event as $name) { |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
292 |
$listeners[] = $this->attach($name, $callback, $priority); |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
293 |
} |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
294 |
return $listeners; |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
295 |
} |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
296 |
|
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
297 |
// If we don't have a priority queue for the event yet, create one |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
298 |
if (empty($this->events[$event])) { |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
299 |
$this->events[$event] = new Zend_Stdlib_PriorityQueue(); |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
300 |
} |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
301 |
|
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
302 |
// Create a callback handler, setting the event and priority in its metadata |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
303 |
$listener = new Zend_Stdlib_CallbackHandler($callback, array('event' => $event, 'priority' => $priority)); |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
304 |
|
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
305 |
// Inject the callback handler into the queue |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
306 |
$this->events[$event]->insert($listener, $priority); |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
307 |
return $listener; |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
308 |
} |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
309 |
|
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
310 |
/** |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
311 |
* Attach a listener aggregate |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
312 |
* |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
313 |
* Listener aggregates accept an EventCollection instance, and call attach() |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
314 |
* one or more times, typically to attach to multiple events using local |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
315 |
* methods. |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
316 |
* |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
317 |
* @param Zend_EventManager_ListenerAggregate $aggregate |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
318 |
* @param int $priority If provided, a suggested priority for the aggregate to use |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
319 |
* @return mixed return value of {@link Zend_EventManager_ListenerAggregate::attach()} |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
320 |
*/ |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
321 |
public function attachAggregate(Zend_EventManager_ListenerAggregate $aggregate, $priority = 1) |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
322 |
{ |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
323 |
return $aggregate->attach($this, $priority); |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
324 |
} |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
325 |
|
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
326 |
/** |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
327 |
* Unsubscribe a listener from an event |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
328 |
* |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
329 |
* @param Zend_Stdlib_CallbackHandler|Zend_EventManager_ListenerAggregate $listener |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
330 |
* @return bool Returns true if event and listener found, and unsubscribed; returns false if either event or listener not found |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
331 |
* @throws Zend_EventManager_Exception_InvalidArgumentException if invalid listener provided |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
332 |
*/ |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
333 |
public function detach($listener) |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
334 |
{ |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
335 |
if ($listener instanceof Zend_EventManager_ListenerAggregate) { |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
336 |
return $this->detachAggregate($listener); |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
337 |
} |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
338 |
|
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
339 |
if (!$listener instanceof Zend_Stdlib_CallbackHandler) { |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
340 |
require_once 'Zend/EventManager/Exception/InvalidArgumentException.php'; |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
341 |
throw new Zend_EventManager_Exception_InvalidArgumentException(sprintf( |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
342 |
'%s: expected a Zend_EventManager_ListenerAggregate or Zend_Stdlib_CallbackHandler; received "%s"', |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
343 |
__METHOD__, |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
344 |
(is_object($listener) ? get_class($listener) : gettype($listener)) |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
345 |
)); |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
346 |
} |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
347 |
|
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
348 |
$event = $listener->getMetadatum('event'); |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
349 |
if (!$event || empty($this->events[$event])) { |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
350 |
return false; |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
351 |
} |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
352 |
$return = $this->events[$event]->remove($listener); |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
353 |
if (!$return) { |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
354 |
return false; |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
355 |
} |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
356 |
if (!count($this->events[$event])) { |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
357 |
unset($this->events[$event]); |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
358 |
} |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
359 |
return true; |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
360 |
} |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
361 |
|
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
362 |
/** |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
363 |
* Detach a listener aggregate |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
364 |
* |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
365 |
* Listener aggregates accept an EventCollection instance, and call detach() |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
366 |
* of all previously attached listeners. |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
367 |
* |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
368 |
* @param Zend_EventManager_ListenerAggregate $aggregate |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
369 |
* @return mixed return value of {@link Zend_EventManager_ListenerAggregate::detach()} |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
370 |
*/ |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
371 |
public function detachAggregate(Zend_EventManager_ListenerAggregate $aggregate) |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
372 |
{ |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
373 |
return $aggregate->detach($this); |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
374 |
} |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
375 |
|
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
376 |
/** |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
377 |
* Retrieve all registered events |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
378 |
* |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
379 |
* @return array |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
380 |
*/ |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
381 |
public function getEvents() |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
382 |
{ |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
383 |
return array_keys($this->events); |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
384 |
} |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
385 |
|
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
386 |
/** |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
387 |
* Retrieve all listeners for a given event |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
388 |
* |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
389 |
* @param string $event |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
390 |
* @return Zend_Stdlib_PriorityQueue |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
391 |
*/ |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
392 |
public function getListeners($event) |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
393 |
{ |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
394 |
if (!array_key_exists($event, $this->events)) { |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
395 |
return new Zend_Stdlib_PriorityQueue(); |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
396 |
} |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
397 |
return $this->events[$event]; |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
398 |
} |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
399 |
|
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
400 |
/** |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
401 |
* Clear all listeners for a given event |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
402 |
* |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
403 |
* @param string $event |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
404 |
* @return void |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
405 |
*/ |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
406 |
public function clearListeners($event) |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
407 |
{ |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
408 |
if (!empty($this->events[$event])) { |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
409 |
unset($this->events[$event]); |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
410 |
} |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
411 |
} |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
412 |
|
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
413 |
/** |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
414 |
* Prepare arguments |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
415 |
* |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
416 |
* Use this method if you want to be able to modify arguments from within a |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
417 |
* listener. It returns an ArrayObject of the arguments, which may then be |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
418 |
* passed to trigger() or triggerUntil(). |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
419 |
* |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
420 |
* @param array $args |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
421 |
* @return ArrayObject |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
422 |
*/ |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
423 |
public function prepareArgs(array $args) |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
424 |
{ |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
425 |
return new ArrayObject($args); |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
426 |
} |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
427 |
|
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
428 |
/** |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
429 |
* Trigger listeners |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
430 |
* |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
431 |
* Actual functionality for triggering listeners, to which both trigger() and triggerUntil() |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
432 |
* delegate. |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
433 |
* |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
434 |
* @param string $event Event name |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
435 |
* @param EventDescription $e |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
436 |
* @param null|callback $callback |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
437 |
* @return ResponseCollection |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
438 |
*/ |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
439 |
protected function triggerListeners($event, Zend_EventManager_EventDescription $e, $callback = null) |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
440 |
{ |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
441 |
$responses = new Zend_EventManager_ResponseCollection; |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
442 |
$listeners = $this->getListeners($event); |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
443 |
|
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
444 |
// Add shared/wildcard listeners to the list of listeners, |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
445 |
// but don't modify the listeners object |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
446 |
$sharedListeners = $this->getSharedListeners($event); |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
447 |
$sharedWildcardListeners = $this->getSharedListeners('*'); |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
448 |
$wildcardListeners = $this->getListeners('*'); |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
449 |
if (count($sharedListeners) || count($sharedWildcardListeners) || count($wildcardListeners)) { |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
450 |
$listeners = clone $listeners; |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
451 |
} |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
452 |
|
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
453 |
// Shared listeners on this specific event |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
454 |
$this->insertListeners($listeners, $sharedListeners); |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
455 |
|
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
456 |
// Shared wildcard listeners |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
457 |
$this->insertListeners($listeners, $sharedWildcardListeners); |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
458 |
|
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
459 |
// Add wildcard listeners |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
460 |
$this->insertListeners($listeners, $wildcardListeners); |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
461 |
|
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
462 |
if ($listeners->isEmpty()) { |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
463 |
return $responses; |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
464 |
} |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
465 |
|
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
466 |
foreach ($listeners as $listener) { |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
467 |
// Trigger the listener's callback, and push its result onto the |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
468 |
// response collection |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
469 |
$responses->push(call_user_func($listener->getCallback(), $e)); |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
470 |
|
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
471 |
// If the event was asked to stop propagating, do so |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
472 |
if ($e->propagationIsStopped()) { |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
473 |
$responses->setStopped(true); |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
474 |
break; |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
475 |
} |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
476 |
|
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
477 |
// If the result causes our validation callback to return true, |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
478 |
// stop propagation |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
479 |
if ($callback && call_user_func($callback, $responses->last())) { |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
480 |
$responses->setStopped(true); |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
481 |
break; |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
482 |
} |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
483 |
} |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
484 |
|
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
485 |
return $responses; |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
486 |
} |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
487 |
|
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
488 |
/** |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
489 |
* Get list of all listeners attached to the shared collection for |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
490 |
* identifiers registered by this instance |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
491 |
* |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
492 |
* @param string $event |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
493 |
* @return array |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
494 |
*/ |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
495 |
protected function getSharedListeners($event) |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
496 |
{ |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
497 |
if (!$sharedCollections = $this->getSharedCollections()) { |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
498 |
return array(); |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
499 |
} |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
500 |
|
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
501 |
$identifiers = $this->getIdentifiers(); |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
502 |
$sharedListeners = array(); |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
503 |
|
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
504 |
foreach ($identifiers as $id) { |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
505 |
if (!$listeners = $sharedCollections->getListeners($id, $event)) { |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
506 |
continue; |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
507 |
} |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
508 |
|
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
509 |
if (!is_array($listeners) && !($listeners instanceof Traversable)) { |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
510 |
continue; |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
511 |
} |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
512 |
|
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
513 |
foreach ($listeners as $listener) { |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
514 |
if (!$listener instanceof Zend_Stdlib_CallbackHandler) { |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
515 |
continue; |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
516 |
} |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
517 |
$sharedListeners[] = $listener; |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
518 |
} |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
519 |
} |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
520 |
|
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
521 |
return $sharedListeners; |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
522 |
} |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
523 |
|
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
524 |
/** |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
525 |
* Add listeners to the master queue of listeners |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
526 |
* |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
527 |
* Used to inject shared listeners and wildcard listeners. |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
528 |
* |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
529 |
* @param Zend_Stdlib_PriorityQueue $masterListeners |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
530 |
* @param Zend_Stdlib_PriorityQueue $listeners |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
531 |
* @return void |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
532 |
*/ |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
533 |
protected function insertListeners($masterListeners, $listeners) |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
534 |
{ |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
535 |
if (!count($listeners)) { |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
536 |
return; |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
537 |
} |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
538 |
|
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
539 |
foreach ($listeners as $listener) { |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
540 |
$priority = $listener->getMetadatum('priority'); |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
541 |
if (null === $priority) { |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
542 |
$priority = 1; |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
543 |
} elseif (is_array($priority)) { |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
544 |
// If we have an array, likely using PriorityQueue. Grab first |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
545 |
// element of the array, as that's the actual priority. |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
546 |
$priority = array_shift($priority); |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
547 |
} |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
548 |
$masterListeners->insert($listener, $priority); |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
549 |
} |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
550 |
} |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
551 |
} |