-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.php
54 lines (47 loc) · 1.59 KB
/
example.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
/**
* Epub loader - example of extra actions defined in your app
*
* You can add extra actions on databases and/or epub files by extending
* the ActionHandler class and adding your own methods here. If you name
* the class something other than 'ExtraActions', be sure to change this
* line in index.php:
*
* $handler = new RequestHandler($gConfig, ExtraActions::class);
*
* and run 'composer dump-autoload -o' to let the autoloader find it
*/
namespace Marsender\EPubLoader\App;
use Marsender\EPubLoader\ActionHandler;
/**
* Extra actions defined as an example - add your own here or replace
*/
class ExtraActions extends ActionHandler
{
/**
* Summary of hello_world
* @return array<mixed>|string|null
*/
public function hello_world()
{
// you can access the selected database config here (name, db_path, epub_path, ...)
$dbName = $this->dbConfig['name'];
// any additional parameters you need to grab yourself
$name = $this->request->get('name', 'World!');
// do the action and build the result
$result = 'Hello, ' . $name . ' for database ' . $dbName;
// return an array containing the result(s) or see below
return ['result' => $result, 'name' => $name];
}
/**
* Summary of goodbye
* @return array<mixed>|string|null
*/
public function goodbye()
{
// you can report errors in your action too
$this->addError(basename(__FILE__), 'Why leave so soon?');
// or return a simple text string if you want
return 'Goodbye from ' . $this->dbFileName;
}
}