alltube/classes/Factory/DebugBarFactory.php

49 lines
1.4 KiB
PHP
Raw Normal View History

2021-02-06 14:00:26 +00:00
<?php
namespace Alltube\Factory;
use DebugBar\DataCollector\ConfigCollector;
use DebugBar\DataCollector\MemoryCollector;
use DebugBar\DataCollector\MessagesCollector;
use DebugBar\DataCollector\PhpInfoCollector;
use DebugBar\DataCollector\RequestDataCollector;
use DebugBar\DebugBar;
use DebugBar\DebugBarException;
2021-02-07 11:24:16 +00:00
use Kitchenu\Debugbar\DataCollector\SlimRouteCollector;
2021-02-06 14:00:26 +00:00
use Slim\Container;
/**
* Class DebugBarFactory
* @package Alltube\Factory
*/
class DebugBarFactory
{
/**
* @param Container $container
* @return DebugBar
* @throws DebugBarException
*/
public static function create(Container $container): DebugBar
{
$debugBar = new DebugBar();
$requestCollector = new RequestDataCollector();
$configCollector = new ConfigCollector(get_object_vars($container->get('config')));
$debugBar->addCollector(new PhpInfoCollector())
->addCollector(new MessagesCollector())
->addCollector($requestCollector)
->addCollector(new MemoryCollector())
2021-02-07 11:24:16 +00:00
->addCollector($configCollector)
->addCollector(new SlimRouteCollector($container->get('router'), $container->get('request')));
2021-02-06 14:00:26 +00:00
$container->get('logger')->add('debugbar', $debugBar->getCollector('messages'));
$requestCollector->useHtmlVarDumper();
$configCollector->useHtmlVarDumper();
return $debugBar;
}
}