a6e9c08499
- each route will be prefixed by `/plugin/<plugin_name>` - add a new template for plugins rendering - add a live example in the demo_plugin Check out the "Plugin System" documentation for more detail. Related to #143
45 lines
918 B
PHP
45 lines
918 B
PHP
<?php
|
|
|
|
/**
|
|
* 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';
|
|
} elseif (isset($data['_LOGGEDIN_']) && $data['_LOGGEDIN_'] === true) {
|
|
$data[1] = 'loggedin';
|
|
} elseif (array_key_exists('_LOGGEDIN_', $data)) {
|
|
$data[1] = 'loggedin';
|
|
$data[2] = $data['_LOGGEDIN_'];
|
|
} else {
|
|
$data[1] = $data[0];
|
|
}
|
|
|
|
return $data;
|
|
}
|
|
|
|
function hook_test_error()
|
|
{
|
|
new Unknown();
|
|
}
|
|
|
|
function test_register_routes(): array
|
|
{
|
|
return [
|
|
[
|
|
'method' => 'GET',
|
|
'route' => '/test',
|
|
'callable' => 'getFunction',
|
|
],
|
|
[
|
|
'method' => 'POST',
|
|
'route' => '/custom',
|
|
'callable' => 'postFunction',
|
|
],
|
|
];
|
|
}
|