-
Notifications
You must be signed in to change notification settings - Fork 2
/
controller.php
53 lines (43 loc) · 1.5 KB
/
controller.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
namespace Concrete\Package\KintDebug;
use Illuminate\Filesystem\Filesystem;;
use Concrete\Core\Package\Package;
use View;
use Config;
defined('C5_EXECUTE') or die(_('Access Denied.'));
$fs = new Filesystem();
$fs->getRequire(__DIR__ . '/vendor/autoload.php');
class Controller extends Package {
protected $pkgHandle = 'kint_debug';
protected $appVersionRequired = '5.7.0.4';
protected $pkgVersion = '0.9.5';
public function getPackageDescription() {
return t('Add Kint debugging tools');
}
public function getPackageName() {
return t('Debug Kit');
}
public function on_start() {
$al = \Concrete\Core\Asset\AssetList::getInstance();
$al->register('css', $this->pkgHandle . '/css', 'css/debug.css', array(), $this->pkgHandle);
$displayErrors = Config::get('concrete.debug.display_errors');
// Only enable Kint if display_errors is true
if (!$displayErrors) {
\Kint::enabled(false);
}
else {
// Never include the css in ajax responses
if(!$this->isAjaxRequest()) {
View::getInstance()->requireAsset('css', $this->pkgHandle . '/css');
}
}
}
/**
* Check, if possible, that this execution was triggered by an AJAX request.
* @return bool
*/
protected function isAjaxRequest() {
return !empty($_SERVER['HTTP_X_REQUESTED_WITH']) &&
strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest';
}
}