From e869fd87e680aebf681887e3b2eb74fb16820019 Mon Sep 17 00:00:00 2001 From: Louis Trezzini Date: Thu, 29 Dec 2016 17:47:04 +0100 Subject: [PATCH 1/2] Adding support for Raven options --- .../DependencyInjection/Configuration.php | 5 +++++ .../SentryBundle/Resources/config/services.yml | 2 +- src/Sentry/SentryBundle/SentrySymfonyClient.php | 6 +++--- .../Test/DependencyInjection/ExtensionTest.php | 16 ++++++++++++++++ 4 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/Sentry/SentryBundle/DependencyInjection/Configuration.php b/src/Sentry/SentryBundle/DependencyInjection/Configuration.php index c866ab54..8ce1764e 100644 --- a/src/Sentry/SentryBundle/DependencyInjection/Configuration.php +++ b/src/Sentry/SentryBundle/DependencyInjection/Configuration.php @@ -34,6 +34,11 @@ public function getConfigTreeBuilder() ->scalarNode('dsn') ->defaultNull() ->end() + ->arrayNode('options') + ->treatNullLike(array()) + ->prototype('scalar')->end() + ->defaultValue(array()) + ->end() ->scalarNode('error_types') ->defaultNull() ->end() diff --git a/src/Sentry/SentryBundle/Resources/config/services.yml b/src/Sentry/SentryBundle/Resources/config/services.yml index 41980f86..13e4bb34 100644 --- a/src/Sentry/SentryBundle/Resources/config/services.yml +++ b/src/Sentry/SentryBundle/Resources/config/services.yml @@ -1,7 +1,7 @@ services: sentry.client: class: '%sentry.client%' - arguments: ['%sentry.dsn%', {'error_types': '%sentry.error_types%'}] + arguments: ['%sentry.dsn%', %sentry.options%, '%sentry.error_types%'] calls: - [setRelease, ['%sentry.release%']] - [setEnvironment, ['%sentry.environment%']] diff --git a/src/Sentry/SentryBundle/SentrySymfonyClient.php b/src/Sentry/SentryBundle/SentrySymfonyClient.php index d77a0e3e..062948e4 100644 --- a/src/Sentry/SentryBundle/SentrySymfonyClient.php +++ b/src/Sentry/SentryBundle/SentrySymfonyClient.php @@ -4,10 +4,10 @@ class SentrySymfonyClient extends \Raven_Client { - public function __construct($dsn=null, $options=array()) + public function __construct($dsn=null, $options=array(), $error_types='') { - if (array_key_exists('error_types', $options)) { - $exParser = new ErrorTypesParser($options['error_types']); + if (is_string($error_types) && !empty($error_types)) { + $exParser = new ErrorTypesParser($error_types); $options['error_types'] = $exParser->parse(); } diff --git a/test/Sentry/SentryBundle/Test/DependencyInjection/ExtensionTest.php b/test/Sentry/SentryBundle/Test/DependencyInjection/ExtensionTest.php index 366e72c7..badc860e 100644 --- a/test/Sentry/SentryBundle/Test/DependencyInjection/ExtensionTest.php +++ b/test/Sentry/SentryBundle/Test/DependencyInjection/ExtensionTest.php @@ -115,6 +115,22 @@ public function test_that_it_uses_dsn_value() ); } + public function test_that_it_uses_options_value() + { + $container = $this->getContainer(array( + static::CONFIG_ROOT => array( + 'options' => array( + 'http_proxy' => 'http://user:password@host:port' + ), + ), + )); + + $this->assertSame( + 'http://user:password@host:port', + $container->getParameter('sentry.options')['http_proxy'] + ); + } + public function test_that_it_uses_defined_class_as_exception_listener_class_by_default() { $container = $this->getContainer(); From 20df5931995822205002e6ab2728ed6c1b13593a Mon Sep 17 00:00:00 2001 From: Louis Trezzini Date: Thu, 29 Dec 2016 22:34:18 +0100 Subject: [PATCH 2/2] PHP 5.3 compatibility --- .../SentryBundle/Test/DependencyInjection/ExtensionTest.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/Sentry/SentryBundle/Test/DependencyInjection/ExtensionTest.php b/test/Sentry/SentryBundle/Test/DependencyInjection/ExtensionTest.php index badc860e..1f695c71 100644 --- a/test/Sentry/SentryBundle/Test/DependencyInjection/ExtensionTest.php +++ b/test/Sentry/SentryBundle/Test/DependencyInjection/ExtensionTest.php @@ -125,9 +125,11 @@ public function test_that_it_uses_options_value() ), )); + $options = $container->getParameter('sentry.options'); + $this->assertSame( 'http://user:password@host:port', - $container->getParameter('sentry.options')['http_proxy'] + $options['http_proxy'] ); }