1 | <?php |
||
33 | class IndexController { |
||
34 | |||
35 | /** @var \Pimple\Container */ |
||
36 | protected $container; |
||
37 | |||
38 | /** @var Request */ |
||
39 | protected $request; |
||
40 | |||
41 | /** @var string $command */ |
||
42 | protected $command; |
||
43 | |||
44 | public function __construct(\Pimple\Container $container, $request = null){ |
||
54 | |||
55 | public function dispatch(){ |
||
56 | if (is_null($this->command)){ |
||
57 | if (!isset($_SESSION['updater_ajax_token']) || empty($_SESSION['updater_ajax_token'])){ |
||
58 | $_SESSION['updater_ajax_token'] = $this->getToken(); |
||
59 | } |
||
60 | |||
61 | $checkpoints = $this->container['utils.checkpoint']->getAll(); |
||
62 | |||
63 | // strip index.php and query string (if any) to get a real base url |
||
64 | $baseUrl = preg_replace('/(index\.php.*|\?.*)$/', '', $_SERVER['REQUEST_URI']); |
||
65 | |||
66 | $templates = new Engine(CURRENT_DIR . '/src/Resources/views/'); |
||
67 | $templates->loadExtension(new Asset(CURRENT_DIR . '/pub/', false)); |
||
68 | $templates->loadExtension(new URI($baseUrl)); |
||
69 | |||
70 | // TODO: Check for user permissions |
||
71 | //$content = $templates->render('partials/login', ['title' => 'Login Required']); |
||
72 | $content = $templates->render( |
||
73 | 'partials/inner', |
||
74 | [ |
||
75 | 'title' => 'Updater', |
||
76 | 'token' => $_SESSION['updater_ajax_token'], |
||
77 | 'version' => $this->container['application']->getVersion(), |
||
78 | 'checkpoints' => $checkpoints |
||
79 | ] |
||
80 | ); |
||
81 | } else { |
||
82 | header('Content-Type: application/json'); |
||
83 | $content = json_encode($this->ajaxAction(), JSON_UNESCAPED_SLASHES); |
||
84 | } |
||
85 | return $content; |
||
86 | } |
||
87 | |||
88 | public function ajaxAction(){ |
||
124 | |||
125 | protected function getToken(){ |
||
137 | |||
138 | } |
||
139 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.