Skip to content

Commit

Permalink
Allow custom grouping types
Browse files Browse the repository at this point in the history
  • Loading branch information
mpociot committed Nov 27, 2019
1 parent 6a1d324 commit edb8486
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 1 deletion.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"php": "^7.1",
"ext-json": "*",
"ext-mbstring": "*",
"facade/flare-client-php": "^1.1",
"facade/flare-client-php": "^1.3",
"facade/ignition-contracts": "^1.0",
"filp/whoops": "^2.4",
"illuminate/support": "~5.5.0 || ~5.6.0 || ~5.7.0 || ~5.8.0 || ^6.0",
Expand Down
1 change: 1 addition & 0 deletions config/flare.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
'maximum_number_of_collected_queries' => 200,
'report_query_bindings' => true,
'report_view_data' => true,
'grouping_type' => null,
],

/*
Expand Down
5 changes: 5 additions & 0 deletions src/IgnitionServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
use Facade\Ignition\DumpRecorder\DumpRecorder;
use Facade\Ignition\Middleware\SetNotifierName;
use Facade\Ignition\QueryRecorder\QueryRecorder;
use Facade\Ignition\Middleware\CustomizeGrouping;
use Facade\Ignition\Commands\SolutionMakeCommand;
use Facade\Ignition\Middleware\AddGitInformation;
use Facade\Ignition\Views\Engines\CompilerEngine;
Expand Down Expand Up @@ -332,6 +333,10 @@ protected function registerBuiltInMiddleware()
$middleware[] = (new AddGitInformation());
}

if (! is_null(config('flare.reporting.grouping_type'))) {
$middleware[] = new CustomizeGrouping(config('flare.reporting.grouping_type'));
}

foreach ($middleware as $singleMiddleware) {
$this->app->get('flare.client')->registerMiddleware($singleMiddleware);
}
Expand Down
27 changes: 27 additions & 0 deletions src/Middleware/CustomizeGrouping.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace Facade\Ignition\Middleware;

use Facade\FlareClient\Report;
use Facade\FlareClient\Enums\GroupingTypes;

class CustomizeGrouping
{
protected $groupingType;

public function __construct($groupingType)
{
$this->groupingType = $groupingType;
}

public function handle(Report $report, $next)
{
$report->groupByTopFrame();

if ($this->groupingType === GroupingTypes::EXCEPTION) {
$report->groupByException();
}

return $next($report);
}
}

0 comments on commit edb8486

Please sign in to comment.