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