Skip to content

Commit

Permalink
Sentry: Add enabled config option
Browse files Browse the repository at this point in the history
  • Loading branch information
RiKap authored and Milan Felix Šulc committed Sep 9, 2018
1 parent 67a02b3 commit 83448a5
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/DI/SentryLoggingExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ final class SentryLoggingExtension extends CompilerExtension
/** @var array */
private $defaults = [
'url' => NULL,
'enabled' => TRUE,
];

/**
Expand All @@ -25,8 +26,10 @@ public function loadConfiguration()
{
$builder = $this->getContainerBuilder();
$config = $this->validateConfig($this->defaults);
if ($config['enabled'] === FALSE) return;

Validators::assertField($config, 'url', 'string', 'sentry URL (%)');
Validators::assertField($config, 'enabled', 'bool');

$builder->addDefinition($this->prefix('logger'))
->setClass(SentryLogger::class, [$config]);
Expand All @@ -40,6 +43,8 @@ public function loadConfiguration()
public function beforeCompile()
{
$builder = $this->getContainerBuilder();
$config = $this->validateConfig($this->defaults);

This comment has been minimized.

Copy link
@jkuchar

jkuchar Sep 9, 2018

Contributor

is second validation here really needed?

if ($config['enabled'] === FALSE) return;

$logger = $builder->getByType(UniversalLogger::class);
if ($logger === NULL) {
Expand Down

0 comments on commit 83448a5

Please sign in to comment.