]> git.immae.eu Git - github/shaarli/Shaarli.git/blame - application/api/controllers/ApiController.php
Merge pull request #1616 from dimtion/fix-api-redirect
[github/shaarli/Shaarli.git] / application / api / controllers / ApiController.php
CommitLineData
18e67967
A
1<?php
2
3namespace Shaarli\Api\Controllers;
4
cf92b4dd 5use Shaarli\Bookmark\BookmarkServiceInterface;
813849e5 6use Shaarli\Config\ConfigManager;
b06fc28a 7use Shaarli\History;
dea72c71 8use Slim\Container;
18e67967
A
9
10/**
11 * Abstract Class ApiController
12 *
13 * Defines REST API Controller dependencies injected from the container.
14 *
15 * @package Api\Controllers
16 */
17abstract class ApiController
18{
19 /**
20 * @var Container
21 */
22 protected $ci;
23
24 /**
813849e5 25 * @var ConfigManager
18e67967
A
26 */
27 protected $conf;
28
29 /**
cf92b4dd 30 * @var BookmarkServiceInterface
18e67967 31 */
cf92b4dd 32 protected $bookmarkService;
18e67967 33
813849e5 34 /**
b06fc28a 35 * @var History
813849e5
A
36 */
37 protected $history;
38
18e67967
A
39 /**
40 * @var int|null JSON style option.
41 */
42 protected $jsonStyle;
43
44 /**
45 * ApiController constructor.
f211e417 46 *
18e67967
A
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');
cf92b4dd 55 $this->bookmarkService = $ci->get('db');
813849e5 56 $this->history = $ci->get('history');
18e67967
A
57 if ($this->conf->get('dev.debug', false)) {
58 $this->jsonStyle = JSON_PRETTY_PRINT;
59 } else {
60 $this->jsonStyle = null;
61 }
62 }
68016e37
A
63
64 /**
65 * Get the container.
66 *
67 * @return Container
68 */
69 public function getCi()
70 {
71 return $this->ci;
72 }
18e67967 73}