Debian Codegraph @

library/Toplevelview/Web/Controller.php

raw
1 <?php
2 /* Copyright (C) 2017 Icinga Development Team <[email protected]> */
3
4 namespace Icinga\Module\Toplevelview\Web;
5
6 use Icinga\Exception\ConfigurationError;
7 use ipl\Web\Compat\CompatController;
8
9 /**
10 * Controller wraps around the Icinga\Web\Controller to
11 * check for the PHP YAML extension
12 *
13 * @codeCoverageIgnore
14 * @throws ConfigurationError if the PHP yaml extension is not loaded
15 */
16 class Controller extends CompatController
17 {
18 public function init()
19 {
20 parent::init();
21
22 if (! extension_loaded('yaml')) {
23 throw new ConfigurationError('You need the PHP extension "yaml" in order to use TopLevelView');
24 }
25 }
26
27 protected function setViewScript($name, $controller = null): void
28 {
29 if ($controller !== null) {
30 $name = sprintf('%s/%s', $controller, $name);
31 }
32 $this->_helper->viewRenderer->setNoController(true);
33 $this->_helper->viewRenderer->setScriptAction($name);
34 }
35 }