| 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_Stdlib |
|
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 |
/** |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
22 |
* CallbackHandler |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
23 |
* |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
24 |
* A handler for a event, event, filterchain, etc. Abstracts PHP callbacks, |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
25 |
* primarily to allow for lazy-loading and ensuring availability of default |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
26 |
* arguments (currying). |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
27 |
* |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
28 |
* @category Zend |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
29 |
* @package Zend_Stdlib |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
30 |
* @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
|
31 |
* @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
|
32 |
*/ |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
33 |
class Zend_Stdlib_CallbackHandler |
|
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 |
/** |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
36 |
* @var string|array PHP callback to invoke |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
37 |
*/ |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
38 |
protected $callback; |
|
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 |
/** |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
41 |
* Did an error occur when testing the validity of the callback? |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
42 |
* @var bool |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
43 |
*/ |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
44 |
protected $error = false; |
|
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 |
/** |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
47 |
* Callback metadata, if any |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
48 |
* @var array |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
49 |
*/ |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
50 |
protected $metadata; |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
51 |
|
|
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 |
* Constructor |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
54 |
* |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
55 |
* @param string $event Event to which slot is subscribed |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
56 |
* @param string|array|object $callback PHP callback |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
57 |
* @param array $options Options used by the callback handler (e.g., priority) |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
58 |
* @return void |
|
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 |
public function __construct($callback, array $metadata = array()) |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
61 |
{ |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
62 |
$this->metadata = $metadata; |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
63 |
$this->registerCallback($callback); |
|
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 |
/** |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
67 |
* Error handler |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
68 |
* |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
69 |
* Used by registerCallback() when calling is_callable() to capture engine warnings. |
|
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 int $errno |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
72 |
* @param string $errstr |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
73 |
* @return void |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
74 |
*/ |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
75 |
public function errorHandler($errno, $errstr) |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
76 |
{ |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
77 |
$this->error = true; |
|
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 |
/** |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
81 |
* Registers the callback provided in the constructor |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
82 |
* |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
83 |
* If you have pecl/weakref {@see http://pecl.php.net/weakref} installed, |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
84 |
* this method provides additional behavior. |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
85 |
* |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
86 |
* If a callback is a functor, or an array callback composing an object |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
87 |
* instance, this method will pass the object to a WeakRef instance prior |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
88 |
* to registering the callback. |
|
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 |
* @param Callable $callback |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
91 |
* @return void |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
92 |
*/ |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
93 |
protected function registerCallback($callback) |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
94 |
{ |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
95 |
set_error_handler(array($this, 'errorHandler'), E_STRICT); |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
96 |
$callable = is_callable($callback); |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
97 |
restore_error_handler(); |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
98 |
if (!$callable || $this->error) { |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
99 |
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
|
100 |
throw new Zend_Stdlib_Exception_InvalidCallbackException('Invalid callback provided; not callable'); |
|
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 |
// If pecl/weakref is not installed, simply store the callback and return |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
104 |
if (!class_exists('WeakRef')) { |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
105 |
$this->callback = $callback; |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
106 |
return; |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
107 |
} |
|
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 |
// If WeakRef exists, we want to use it. |
|
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 |
// If we have a non-closure object, pass it to WeakRef, and then |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
112 |
// register it. |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
113 |
if (is_object($callback) && !$callback instanceof Closure) { |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
114 |
$this->callback = new WeakRef($callback); |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
115 |
return; |
|
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 |
|
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
118 |
// If we have a string or closure, register as-is |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
119 |
if (!is_array($callback)) { |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
120 |
$this->callback = $callback; |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
121 |
return; |
|
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 |
|
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
124 |
list($target, $method) = $callback; |
|
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 |
// If we have an array callback, and the first argument is not an |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
127 |
// object, register as-is |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
128 |
if (!is_object($target)) { |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
129 |
$this->callback = $callback; |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
130 |
return; |
|
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 |
|
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
133 |
// We have an array callback with an object as the first argument; |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
134 |
// pass it to WeakRef, and then register the new callback |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
135 |
$target = new WeakRef($target); |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
136 |
$this->callback = array($target, $method); |
|
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 |
* Retrieve registered callback |
|
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 |
* @return Callable |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
143 |
*/ |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
144 |
public function getCallback() |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
145 |
{ |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
146 |
$callback = $this->callback; |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
147 |
|
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
148 |
// String callbacks -- simply return |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
149 |
if (is_string($callback)) { |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
150 |
return $callback; |
|
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 |
|
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
153 |
// WeakRef callbacks -- pull it out of the object and return it |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
154 |
if ($callback instanceof WeakRef) { |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
155 |
return $callback->get(); |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
156 |
} |
|
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 |
// Non-WeakRef object callback -- return it |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
159 |
if (is_object($callback)) { |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
160 |
return $callback; |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
161 |
} |
|
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 |
// Array callback with WeakRef object -- retrieve the object first, and |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
164 |
// then return |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
165 |
list($target, $method) = $callback; |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
166 |
if ($target instanceof WeakRef) { |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
167 |
return array($target->get(), $method); |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
168 |
} |
|
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 |
// Otherwise, return it |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
171 |
return $callback; |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
172 |
} |
|
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 |
/** |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
175 |
* Invoke handler |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
176 |
* |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
177 |
* @param array $args Arguments to pass to callback |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
178 |
* @return mixed |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
179 |
*/ |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
180 |
public function call(array $args = array()) |
|
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 |
$callback = $this->getCallback(); |
|
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 |
$isPhp54 = version_compare(PHP_VERSION, '5.4.0rc1', '>='); |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
185 |
|
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
186 |
if ($isPhp54 && is_string($callback)) { |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
187 |
$this->validateStringCallbackFor54($callback); |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
188 |
} |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
189 |
|
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
190 |
// Minor performance tweak; use call_user_func() until > 3 arguments |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
191 |
// reached |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
192 |
switch (count($args)) { |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
193 |
case 0: |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
194 |
if ($isPhp54) { |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
195 |
return $callback(); |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
196 |
} |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
197 |
return call_user_func($callback); |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
198 |
case 1: |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
199 |
if ($isPhp54) { |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
200 |
return $callback(array_shift($args)); |
|
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 |
return call_user_func($callback, array_shift($args)); |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
203 |
case 2: |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
204 |
$arg1 = array_shift($args); |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
205 |
$arg2 = array_shift($args); |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
206 |
if ($isPhp54) { |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
207 |
return $callback($arg1, $arg2); |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
208 |
} |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
209 |
return call_user_func($callback, $arg1, $arg2); |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
210 |
case 3: |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
211 |
$arg1 = array_shift($args); |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
212 |
$arg2 = array_shift($args); |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
213 |
$arg3 = array_shift($args); |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
214 |
if ($isPhp54) { |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
215 |
return $callback($arg1, $arg2, $arg3); |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
216 |
} |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
217 |
return call_user_func($callback, $arg1, $arg2, $arg3); |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
218 |
default: |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
219 |
return call_user_func_array($callback, $args); |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
220 |
} |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
221 |
} |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
222 |
|
|
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 |
* Invoke as functor |
|
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 |
* @return mixed |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
227 |
*/ |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
228 |
public function __invoke() |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
229 |
{ |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
230 |
return $this->call(func_get_args()); |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
231 |
} |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
232 |
|
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
233 |
/** |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
234 |
* Get all callback metadata |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
235 |
* |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
236 |
* @return array |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
237 |
*/ |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
238 |
public function getMetadata() |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
239 |
{ |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
240 |
return $this->metadata; |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
241 |
} |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
242 |
|
|
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 |
* Retrieve a single metadatum |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
245 |
* |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
246 |
* @param string $name |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
247 |
* @return mixed |
|
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 |
public function getMetadatum($name) |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
250 |
{ |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
251 |
if (array_key_exists($name, $this->metadata)) { |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
252 |
return $this->metadata[$name]; |
|
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 |
return null; |
|
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 |
|
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
257 |
/** |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
258 |
* Validate a static method call |
|
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 |
* Validates that a static method call in PHP 5.4 will actually work |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
261 |
* |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
262 |
* @param string $callback |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
263 |
* @return true |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
264 |
* @throws Zend_Stdlib_Exception_InvalidCallbackException if invalid |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
265 |
*/ |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
266 |
protected function validateStringCallbackFor54($callback) |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
267 |
{ |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
268 |
if (!strstr($callback, '::')) { |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
269 |
return true; |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
270 |
} |
|
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 |
list($class, $method) = explode('::', $callback, 2); |
|
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 |
if (!class_exists($class)) { |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
275 |
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
|
276 |
throw new Zend_Stdlib_Exception_InvalidCallbackException(sprintf( |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
277 |
'Static method call "%s" refers to a class that does not exist', |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
278 |
$callback |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
279 |
)); |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
280 |
} |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
281 |
|
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
282 |
$r = new ReflectionClass($class); |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
283 |
if (!$r->hasMethod($method)) { |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
284 |
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
|
285 |
throw new Zend_Stdlib_Exception_InvalidCallbackException(sprintf( |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
286 |
'Static method call "%s" refers to a method that does not exist', |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
287 |
$callback |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
288 |
)); |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
289 |
} |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
290 |
$m = $r->getMethod($method); |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
291 |
if (!$m->isStatic()) { |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
292 |
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
|
293 |
throw new Zend_Stdlib_Exception_InvalidCallbackException(sprintf( |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
294 |
'Static method call "%s" refers to a method that is not static', |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
295 |
$callback |
|
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 |
} |
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
298 |
|
|
6b6c2214f778
update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
299 |
return true; |
|
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 |
} |