1 | <?php |
||
2 | /** |
||
3 | * EGroupware API: push JSON commands to client |
||
4 | * |
||
5 | * @link http://www.egroupware.org |
||
6 | * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License |
||
7 | * @package api |
||
8 | * @subpackage json |
||
9 | * @author Ralf Becker <[email protected]> |
||
10 | */ |
||
11 | |||
12 | namespace EGroupware\Api\Json; |
||
13 | |||
14 | use EGroupware\Api; |
||
15 | |||
16 | /** |
||
17 | * Class to push JSON commands to client |
||
18 | */ |
||
19 | class Push extends Msg |
||
20 | { |
||
21 | /** |
||
22 | * Available backends to try |
||
23 | * |
||
24 | * @var array |
||
25 | */ |
||
26 | protected static $backends = array( |
||
27 | 'notifications_push', |
||
28 | ); |
||
29 | /** |
||
30 | * Backend to use |
||
31 | * |
||
32 | * @var egw_json_push_backend |
||
0 ignored issues
–
show
|
|||
33 | */ |
||
34 | protected static $backend; |
||
35 | |||
36 | /** |
||
37 | * account_id we are pushing too |
||
38 | * |
||
39 | * @var int |
||
40 | */ |
||
41 | protected $account_id; |
||
42 | |||
43 | /** |
||
44 | * Push to all clients / broadcast |
||
45 | */ |
||
46 | const ALL = 0; |
||
47 | /** |
||
48 | * Push to current session |
||
49 | */ |
||
50 | const SESSION = null; |
||
51 | |||
52 | /** |
||
53 | * |
||
54 | * @param int $account_id =null account_id to push message too or |
||
55 | * self::SESSION(=null): for current session only or self::ALL(=0) for whole instance / broadcast |
||
56 | */ |
||
57 | public function __construct($account_id=self::SESSION) |
||
58 | { |
||
59 | $this->account_id = $account_id; |
||
60 | } |
||
61 | |||
62 | /** |
||
63 | * Adds any type of data to the message |
||
64 | * |
||
65 | * @param string $key |
||
66 | * @param mixed $data |
||
67 | * @throws Exception\NotOnline if $account_id is not online |
||
68 | */ |
||
69 | protected function addGeneric($key, $data) |
||
70 | { |
||
71 | if (!isset(self::$backend)) |
||
72 | { |
||
73 | // we prepend so the default backend stays last |
||
74 | foreach(Api\Hooks::process('push-backends', [], true) as $class) |
||
75 | { |
||
76 | if (!empty($class)) |
||
77 | { |
||
78 | array_unshift(self::$backends, $class); |
||
79 | } |
||
80 | } |
||
81 | foreach(self::$backends as $class) |
||
82 | { |
||
83 | if (class_exists($class)) |
||
84 | { |
||
85 | try { |
||
86 | self::$backend = new $class; |
||
87 | break; |
||
88 | } |
||
89 | catch (\Exception $e) { |
||
90 | // ignore all exceptions |
||
91 | unset($e); |
||
92 | self::$backend = null; |
||
93 | } |
||
94 | } |
||
95 | } |
||
96 | if (!isset(self::$backend)) |
||
97 | { |
||
98 | throw new Exception\NotOnline('No valid push-backend found!'); |
||
99 | } |
||
100 | } |
||
101 | self::$backend->addGeneric($this->account_id, $key, $data); |
||
102 | } |
||
103 | } |
||
104 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths