-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontroller.php
More file actions
93 lines (68 loc) · 2.3 KB
/
controller.php
File metadata and controls
93 lines (68 loc) · 2.3 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<?php
namespace Concrete\Package\Concrete5Debug;
require 'vendor/autoload.php';
use DebugBar\DebugBar;
use DebugBar\StandardDebugBar;
use DebugBar\Bridge\DoctrineCollector;
use Core;
use Package;
use Database;
use View;
use Events;
use Illuminate\Support\ServiceProvider;
use Doctrine;
class Controller extends Package {
protected $pkgHandle = 'concrete5_debug';
protected $pkgName = 'Concrete Debugbar';
protected $pkgDescription = 'Concrete5 Debugging information';
protected $appVersionRequired = '5.7';
protected $pkgVersion = '0.0.1';
public function getPackageDescription()
{
return t("Concrete Debug");
}
public function getPackageName()
{
return t("Concrete Debug");
}
public function __construct()
{
}
public function install()
{
parent::install();
}
public function upgrade()
{
parent::upgrade();
}
public function on_start()
{
Core::instance('DebugBar', $bar = new StandardDebugBar());
$debugStack = new \Doctrine\DBAL\Logging\DebugStack();
$bar['time']->startMeasure('c5start', 'Concrete5 Boot');
// $bar['time']->measure('My long operation', function() {
// sleep(2);
// });
try {
throw new \Exception('This is a test exception');
} catch (\Exception $e) {
$bar['exceptions']->addException($e);
}
$message = 'This is a string message variable';
$bar['messages']->addMessage($message);
// Cache javascript renderer object.
$renderer = $bar->getJavascriptRenderer('/packages/concrete5_debug/vendor/maximebf/debugbar/src/DebugBar/Resources/');
Database::connection()->getConfiguration()->setSQLLogger($debugStack);
$bar->addCollector(new DoctrineCollector($debugStack));
// enqueuing on_start means this gets added to everything, even php rendered javascript files, which we want to avoid
if( ! strpos($_SERVER['REQUEST_URI'], 'i18n_js') > 0 ){
View::getInstance()->addHeaderItem($renderer->renderHead());
}
Events::addListener('on_before_render', function() use ($renderer, $bar) {
View::getInstance()->addFooterItem($renderer->render());
});
$bar['time']->stopMeasure('c5start');
}
}
?>