]> git.immae.eu Git - github/shaarli/Shaarli.git/blame - application/api/controllers/ApiController.php
Optimize and cleanup imports
[github/shaarli/Shaarli.git] / application / api / controllers / ApiController.php
CommitLineData
18e67967
A
1<?php
2
3namespace Shaarli\Api\Controllers;
4
dea72c71 5use Shaarli\Bookmark\LinkDB;
813849e5 6use Shaarli\Config\ConfigManager;
dea72c71 7use 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 */
16abstract 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 /**
dea72c71 29 * @var LinkDB
18e67967
A
30 */
31 protected $linkDb;
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');
54 $this->linkDb = $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}