2015-07-15 11:42:15 +02:00
|
|
|
<?php
|
|
|
|
|
2021-01-20 15:59:00 +01:00
|
|
|
use Shaarli\Bookmark\Bookmark;
|
|
|
|
|
2015-07-15 11:42:15 +02:00
|
|
|
/**
|
|
|
|
* Hook for test.
|
|
|
|
*
|
|
|
|
* @param array $data - data passed to plugin.
|
|
|
|
*
|
|
|
|
* @return mixed altered data.
|
|
|
|
*/
|
|
|
|
function hook_test_random($data)
|
|
|
|
{
|
|
|
|
if (isset($data['_PAGE_']) && $data['_PAGE_'] == 'test') {
|
|
|
|
$data[1] = 'page test';
|
2018-02-28 22:34:40 +01:00
|
|
|
} elseif (isset($data['_LOGGEDIN_']) && $data['_LOGGEDIN_'] === true) {
|
2015-07-15 11:42:15 +02:00
|
|
|
$data[1] = 'loggedin';
|
2020-09-10 14:08:19 +02:00
|
|
|
} elseif (array_key_exists('_LOGGEDIN_', $data)) {
|
|
|
|
$data[1] = 'loggedin';
|
|
|
|
$data[2] = $data['_LOGGEDIN_'];
|
2015-07-15 11:42:15 +02:00
|
|
|
} else {
|
|
|
|
$data[1] = $data[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
return $data;
|
|
|
|
}
|
2020-08-27 12:04:36 +02:00
|
|
|
|
|
|
|
function hook_test_error()
|
|
|
|
{
|
|
|
|
new Unknown();
|
|
|
|
}
|
2020-10-27 19:23:45 +01:00
|
|
|
|
|
|
|
function test_register_routes(): array
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
[
|
|
|
|
'method' => 'GET',
|
|
|
|
'route' => '/test',
|
|
|
|
'callable' => 'getFunction',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'method' => 'POST',
|
|
|
|
'route' => '/custom',
|
|
|
|
'callable' => 'postFunction',
|
|
|
|
],
|
|
|
|
];
|
|
|
|
}
|
2021-01-20 15:59:00 +01:00
|
|
|
|
|
|
|
function hook_test_filter_search_entry(Bookmark $bookmark, array $context): bool
|
|
|
|
{
|
|
|
|
return $context['_result'];
|
|
|
|
}
|