Skip to content

Commit

Permalink
Merge 894cd01 into 7e4f09e
Browse files Browse the repository at this point in the history
  • Loading branch information
esbenp committed Apr 17, 2017
2 parents 7e4f09e + 894cd01 commit a562224
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/ExceptionHandler.php
Expand Up @@ -71,7 +71,7 @@ public function report(Exception $e)

$config = isset($reporter['config']) && is_array($reporter['config']) ? $reporter['config'] : [];

$reporterInstance = $this->container->make($class, [$config]);
$reporterInstance = $this->container->make($class)($config);

$this->reportResponses[$key] = $reporterInstance->report($e);
}
Expand Down
18 changes: 18 additions & 0 deletions src/Provider/LaravelServiceProvider.php
Expand Up @@ -3,13 +3,16 @@
namespace Optimus\Heimdal\Provider;

use Illuminate\Support\ServiceProvider as BaseProvider;
use Optimus\Heimdal\Reporters\BugsnagReporter;
use Optimus\Heimdal\Reporters\SentryReporter;

class LaravelServiceProvider extends BaseProvider {

public function register()
{
$this->loadConfig();
$this->registerAssets();
$this->bindReporters();
}

private function registerAssets()
Expand All @@ -25,4 +28,19 @@ private function loadConfig()
$this->app['config']->set('optimus.heimdal', require __DIR__.'/../config/optimus.heimdal.php');
}
}

private function bindReporters()
{
$this->app->bind(BugsnagReporter::class, function ($app) {
return function (array $config) {
return new BugsnagReporter($config);
};
});

$this->app->bind(SentryReporter::class, function ($app) {
return function (array $config) {
return new SentryReporter($config);
};
});
}
}
6 changes: 6 additions & 0 deletions tests/ExceptionHandlerTest.php
Expand Up @@ -38,6 +38,12 @@ public function setUp()
*/
private function createHandler()
{
app()->bind(TestReporter::class, function($app){
return function (array $config) {
return new TestReporter($config);
};
});

return app()->make(ExceptionHandler::class);
}

Expand Down

0 comments on commit a562224

Please sign in to comment.