]>
Commit | Line | Data |
---|---|---|
18e67967 A |
1 | <?php |
2 | ||
3 | namespace Shaarli\Api\Controllers; | |
4 | ||
813849e5 | 5 | use Shaarli\Config\ConfigManager; |
18e67967 A |
6 | use \Slim\Container; |
7 | ||
8 | /** | |
9 | * Abstract Class ApiController | |
10 | * | |
11 | * Defines REST API Controller dependencies injected from the container. | |
12 | * | |
13 | * @package Api\Controllers | |
14 | */ | |
15 | abstract class ApiController | |
16 | { | |
17 | /** | |
18 | * @var Container | |
19 | */ | |
20 | protected $ci; | |
21 | ||
22 | /** | |
813849e5 | 23 | * @var ConfigManager |
18e67967 A |
24 | */ |
25 | protected $conf; | |
26 | ||
27 | /** | |
f24896b2 | 28 | * @var \Shaarli\Bookmark\LinkDB |
18e67967 A |
29 | */ |
30 | protected $linkDb; | |
31 | ||
813849e5 | 32 | /** |
bdc5152d | 33 | * @var \Shaarli\History |
813849e5 A |
34 | */ |
35 | protected $history; | |
36 | ||
18e67967 A |
37 | /** |
38 | * @var int|null JSON style option. | |
39 | */ | |
40 | protected $jsonStyle; | |
41 | ||
42 | /** | |
43 | * ApiController constructor. | |
f211e417 | 44 | * |
18e67967 A |
45 | * Note: enabling debug mode displays JSON with readable formatting. |
46 | * | |
47 | * @param Container $ci Slim container. | |
48 | */ | |
49 | public function __construct(Container $ci) | |
50 | { | |
51 | $this->ci = $ci; | |
52 | $this->conf = $ci->get('conf'); | |
53 | $this->linkDb = $ci->get('db'); | |
813849e5 | 54 | $this->history = $ci->get('history'); |
18e67967 A |
55 | if ($this->conf->get('dev.debug', false)) { |
56 | $this->jsonStyle = JSON_PRETTY_PRINT; | |
57 | } else { | |
58 | $this->jsonStyle = null; | |
59 | } | |
60 | } | |
68016e37 A |
61 | |
62 | /** | |
63 | * Get the container. | |
64 | * | |
65 | * @return Container | |
66 | */ | |
67 | public function getCi() | |
68 | { | |
69 | return $this->ci; | |
70 | } | |
18e67967 | 71 | } |