aboutsummaryrefslogtreecommitdiffhomepage
path: root/application/api/controllers/ApiController.php
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2017-05-07 19:23:32 +0200
committerArthurHoaro <arthur@hoa.ro>2017-05-07 19:23:32 +0200
commitfcf141926da98a4a656a785df991858819961319 (patch)
tree049c1ff6b770e759ca7a96b30e6476b9f18cbfa3 /application/api/controllers/ApiController.php
parent8868f3ca461011a8fb6dd9f90b60ed697ab52fc5 (diff)
parent54c8e8d2998c5ab5ffd08ae8f1fa11276773c16c (diff)
downloadShaarli-fcf141926da98a4a656a785df991858819961319.tar.gz
Shaarli-fcf141926da98a4a656a785df991858819961319.tar.zst
Shaarli-fcf141926da98a4a656a785df991858819961319.zip
Merge tag 'v0.9.0' into latest
Release v0.9.0
Diffstat (limited to 'application/api/controllers/ApiController.php')
-rw-r--r--application/api/controllers/ApiController.php71
1 files changed, 71 insertions, 0 deletions
diff --git a/application/api/controllers/ApiController.php b/application/api/controllers/ApiController.php
new file mode 100644
index 00000000..3be85b98
--- /dev/null
+++ b/application/api/controllers/ApiController.php
@@ -0,0 +1,71 @@
1<?php
2
3namespace Shaarli\Api\Controllers;
4
5use Shaarli\Config\ConfigManager;
6use \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 */
15abstract class ApiController
16{
17 /**
18 * @var Container
19 */
20 protected $ci;
21
22 /**
23 * @var ConfigManager
24 */
25 protected $conf;
26
27 /**
28 * @var \LinkDB
29 */
30 protected $linkDb;
31
32 /**
33 * @var \History
34 */
35 protected $history;
36
37 /**
38 * @var int|null JSON style option.
39 */
40 protected $jsonStyle;
41
42 /**
43 * ApiController constructor.
44 *
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');
54 $this->history = $ci->get('history');
55 if ($this->conf->get('dev.debug', false)) {
56 $this->jsonStyle = JSON_PRETTY_PRINT;
57 } else {
58 $this->jsonStyle = null;
59 }
60 }
61
62 /**
63 * Get the container.
64 *
65 * @return Container
66 */
67 public function getCi()
68 {
69 return $this->ci;
70 }
71}