/var/www/vhosts/ihelp.ro/httpdocs/vendor/cakephp/debug_kit/src
Edit: /var/www/vhosts/ihelp.ro/httpdocs/vendor/cakephp/debug_kit/src/Plugin.php (3981B)
isEnabled()) {
return;
}
$this->service = $service;
$this->setDeprecationHandler($service);
// will load `config/bootstrap.php`.
parent::bootstrap($app);
}
/**
* Add middleware for the plugin.
*
* @param \Cake\Http\MiddlewareQueue $middlewareQueue The middleware queue to update.
* @return \Cake\Http\MiddlewareQueue
*/
public function middleware(MiddlewareQueue $middlewareQueue): MiddlewareQueue
{
// Only insert middleware if Toolbar Service is available (not in phpunit run)
if ($this->service) {
$middlewareQueue->insertAt(0, new DebugKitMiddleware($this->service));
}
return $middlewareQueue;
}
/**
* Add console commands for the plugin.
*
* @param \Cake\Console\CommandCollection $commands The command collection to update
* @return \Cake\Console\CommandCollection
*/
public function console(CommandCollection $commands): CommandCollection
{
return $commands->add('benchmark', BenchmarkCommand::class);
}
/**
* set deprecation handler
*
* @param \DebugKit\ToolbarService $service The toolbar service instance
* @return void
*/
public function setDeprecationHandler($service)
{
if (!empty($service->getConfig('panels')['DebugKit.Deprecations'])) {
EventManager::instance()->on('Error.beforeRender', function (EventInterface $event, PhpError $error) {
$code = $error->getCode();
if ($code !== E_USER_DEPRECATED && $code !== E_DEPRECATED) {
return;
}
$file = $error->getFile();
$line = $error->getLine();
// Extract the line/file from the message as deprecationWarning
// will calculate the application frame when generating the message.
preg_match('/\\n([^\n,]+?), line: (\d+)\\n/', $error->getMessage(), $matches);
if ($matches) {
$file = $matches[1];
$line = $matches[2];
}
DeprecationsPanel::addDeprecatedError([
'code' => $code,
'message' => $error->getMessage(),
'file' => $file,
'line' => $line,
]);
$event->stopPropagation();
});
}
}
}