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