]> git.immae.eu Git - github/shaarli/Shaarli.git/blame - tests/plugins/test/test.php
Plugin system: allow plugins to provide custom routes
[github/shaarli/Shaarli.git] / tests / plugins / test / test.php
CommitLineData
6fc14d53
A
1<?php
2
3/**
4 * Hook for test.
5 *
6 * @param array $data - data passed to plugin.
7 *
8 * @return mixed altered data.
9 */
10function hook_test_random($data)
11{
12 if (isset($data['_PAGE_']) && $data['_PAGE_'] == 'test') {
13 $data[1] = 'page test';
d2d4f993 14 } elseif (isset($data['_LOGGEDIN_']) && $data['_LOGGEDIN_'] === true) {
6fc14d53 15 $data[1] = 'loggedin';
4ff703e3
A
16 } elseif (array_key_exists('_LOGGEDIN_', $data)) {
17 $data[1] = 'loggedin';
18 $data[2] = $data['_LOGGEDIN_'];
6fc14d53
A
19 } else {
20 $data[1] = $data[0];
21 }
22
23 return $data;
24}
7e3dc0ba
A
25
26function hook_test_error()
27{
28 new Unknown();
29}
a6e9c084
A
30
31function test_register_routes(): array
32{
33 return [
34 [
35 'method' => 'GET',
36 'route' => '/test',
37 'callable' => 'getFunction',
38 ],
39 [
40 'method' => 'POST',
41 'route' => '/custom',
42 'callable' => 'postFunction',
43 ],
44 ];
45}