Permalink
Fetching contributors…
Cannot retrieve contributors at this time
59 lines (50 sloc) 1.33 KB
<?php
namespace Equip\Configuration;
use Auryn\Injector;
use Whoops\Handler\JsonResponseHandler;
use Whoops\Handler\PlainTextHandler;
use Whoops\Run as Whoops;
class WhoopsConfiguration implements ConfigurationInterface
{
use EnvTrait;
/**
* @inheritDoc
*/
public function apply(Injector $injector)
{
$injector->prepare(Whoops::class, [$this, 'prepareWhoops']);
$injector->prepare(JsonResponseHandler::class, [$this, 'prepareJsonHandler']);
$injector->prepare(PlainTextHandler::class, [$this, 'preparePlainTextHandler']);
}
/**
* @param Whoops $whoops
*
* @return void
*/
public function prepareWhoops(Whoops $whoops)
{
if($this->env->getValue('DEBUG_STACKTRACE', false) == true) {
set_error_handler([$whoops, Whoops::ERROR_HANDLER]);
}
$whoops->writeToOutput(false);
$whoops->allowQuit(false);
}
/**
* @param JsonResponseHandler $handler
*
* @return void
*/
public function prepareJsonHandler(JsonResponseHandler $handler)
{
$handler->addTraceToOutput(true);
}
/**
* @param PlainTextHandler $handler
*
* @return void
*/
public function preparePlainTextHandler(PlainTextHandler $handler)
{
$handler->addTraceToOutput(true);
}
}