Skip to content

Commit e157606

Browse files
authored
Merge pull request #24 from OxCom/develop
Update rollbar configuration and fix few deprectaions
2 parents 3989118 + a39a468 commit e157606

24 files changed

+153
-97
lines changed

Command/AbstractCommand.php

Lines changed: 0 additions & 35 deletions
This file was deleted.

Command/DeployCommand.php

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,58 @@
22

33
namespace SymfonyRollbarBundle\Command;
44

5+
use Symfony\Component\Console\Command\Command;
56
use Symfony\Component\Console\Input\InputArgument;
67
use Symfony\Component\Console\Input\InputInterface;
78
use Symfony\Component\Console\Input\InputOption;
89
use Symfony\Component\Console\Output\OutputInterface;
10+
use Symfony\Component\Console\Style\SymfonyStyle;
11+
use Symfony\Component\DependencyInjection\ContainerInterface;
912

1013
/**
1114
* Class DeployCommand
1215
*
1316
* @package SymfonyRollbarBundle\Command
1417
*/
15-
class DeployCommand extends \SymfonyRollbarBundle\Command\AbstractCommand
18+
class DeployCommand extends Command
1619
{
1720
protected static $defaultName = 'rollbar:deploy';
1821

22+
/**
23+
* @var \Symfony\Component\Console\Style\SymfonyStyle
24+
*/
25+
protected $io;
26+
27+
/**
28+
* @var \Symfony\Component\DependencyInjection\ContainerInterface
29+
*/
30+
protected $container;
31+
32+
/**
33+
* DeployCommand constructor.
34+
*
35+
* @param \Symfony\Component\DependencyInjection\ContainerInterface $container
36+
*/
37+
public function __construct(ContainerInterface $container)
38+
{
39+
parent::__construct();
40+
41+
$this->container = $container;
42+
}
43+
44+
/**
45+
* Extend the initialize method to add additional parameters to the class.
46+
*
47+
* {@inheritdoc}
48+
*/
49+
public function initialize(InputInterface $input, OutputInterface $output)
50+
{
51+
parent::initialize($input, $output);
52+
53+
$io = new SymfonyStyle($input, $output);
54+
$this->io = $io;
55+
}
56+
1957
/**
2058
* @inheritdoc
2159
*/
@@ -65,9 +103,9 @@ protected function configure()
65103
protected function execute(InputInterface $input, OutputInterface $output)
66104
{
67105
/** @var \SymfonyRollbarBundle\Provider\RollbarHandler $rbHandler */
68-
$rbHandler = $this->getContainer()->get('symfony_rollbar.provider.rollbar_handler');
106+
$rbHandler = $this->container->get('symfony_rollbar.provider.rollbar_handler');
69107

70-
$environment = $this->getContainer()->getParameter('kernel.environment');
108+
$environment = $this->container->getParameter('kernel.environment');
71109
$revision = $input->getArgument('revision');
72110
$comment = $input->getOption('comment');
73111
$rUser = $input->getOption('rollbar_username');

DependencyInjection/Configuration.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ class Configuration implements ConfigurationInterface
2626

2727
const API_ENDPOINT = 'https://api.rollbar.com/api/1/';
2828
const PHP_MAX_ITEMS = 10;
29+
const MIN_OCCURRENCES_LEVEL = 0;
30+
31+
const VERBOSE = 'none';
2932

3033
const JS_ITEMS_PER_MINUTE = 60;
3134
const JS_MAX_ITEMS = 0;
@@ -98,7 +101,6 @@ public function getConfigTreeBuilder()
98101
->booleanNode('capture_error_stacktraces')->defaultTrue()->end()
99102
->scalarNode('check_ignore')->defaultNull()->end()
100103
->scalarNode('code_version')->defaultValue('')->end()
101-
->booleanNode('enable_utf8_sanitization')->defaultTrue()->end()
102104
->scalarNode('environment')->defaultValue(static::ENVIRONMENT)->end()
103105
->arrayNode('custom')
104106
->treatNullLike([])
@@ -159,8 +161,6 @@ public function getConfigTreeBuilder()
159161
->end()
160162
->scalarNode('scrub_whitelist')->defaultNull()->end()
161163
->scalarNode('transformer')->defaultNull()->end()
162-
->scalarNode('verbosity')->defaultValue(\Psr\Log\LogLevel::ERROR)->end()
163-
->booleanNode('shift_function')->defaultTrue()->end()
164164
->scalarNode('timeout')->defaultValue(static::TIMEOUT)->end()
165165
->booleanNode('report_suppressed')->defaultFalse()->end()
166166
->booleanNode('use_error_reporting')->defaultFalse()->end()
@@ -170,6 +170,11 @@ public function getConfigTreeBuilder()
170170
->booleanNode('local_vars_dump')->defaultTrue()->end()
171171
->scalarNode('max_nesting_depth')->defaultValue(-1)->end()
172172
->scalarNode('max_items')->defaultValue(static::PHP_MAX_ITEMS)->end()
173+
->booleanNode('log_payload')->defaultFalse()->end()
174+
->booleanNode('raise_on_error')->defaultFalse()->end()
175+
->booleanNode('transmit')->defaultTrue()->end()
176+
->scalarNode('verbose')->defaultValue(static::VERBOSE)->end()
177+
->scalarNode('minimum_level')->defaultValue(static::MIN_OCCURRENCES_LEVEL)->end()
173178
->end()
174179
->end()
175180
->arrayNode('rollbar_js')->children()

Provider/RollbarHandler.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Monolog\Logger;
77
use Rollbar\Rollbar as RollbarNotifier;
88
use Symfony\Component\DependencyInjection\ContainerInterface;
9+
use Symfony\Component\HttpKernel\Kernel;
910
use SymfonyRollbarBundle\DependencyInjection\SymfonyRollbarExtension;
1011
use Rollbar\Payload\Level;
1112
use SymfonyRollbarBundle\Provider\Api\Filter;
@@ -121,9 +122,13 @@ protected function initialize()
121122
$rConfig = $config['rollbar'];
122123

123124
// override specific values
125+
$root = \method_exists($kernel, 'getProjectDir')
126+
? $kernel->getProjectDir()
127+
: $kernel->getRootDir();
128+
124129
$override = [
125-
'root' => $kernel->getRootDir(),
126-
'framework' => 'Symfony ' . \Symfony\Component\HttpKernel\Kernel::VERSION,
130+
'root' => $root,
131+
'framework' => 'Symfony ' . Kernel::VERSION,
127132
];
128133

129134
foreach ($override as $key => $value) {

Resources/config/services.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ services:
3333

3434
symfony_rollbar.command.deploy:
3535
class: "%symfony_rollbar.command.deploy.class%"
36+
arguments: ["@service_container"]
3637
tags:
3738
- {name: console.command, command: "rollbar:deploy"}
3839

Resources/doc/configuration.rst

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ Simple configuration of bundle:
1919
capture_error_stacktraces: true
2020
check_ignore: null
2121
code_version: ''
22-
enable_utf8_sanitization': true
2322
environment: 'production'
2423
custom:
2524
- {key: hello, value: world}
@@ -47,7 +46,6 @@ Simple configuration of bundle:
4746
root: '%kernel.root_dir%'
4847
scrub_fields: ['passwd', 'password', 'secret', 'confirm_password', 'password_confirmation', 'auth_token', 'csrf_token']
4948
scrub_whitelist: null
50-
shift_function': true
5149
timeout: 3
5250
report_suppressed: false
5351
use_error_reporting: false
@@ -62,7 +60,6 @@ Simple configuration of bundle:
6260
custom_truncation: null
6361
ca_cert_path: null
6462
transformer: null
65-
verbosity: 'error'
6663
rollbar_js:
6764
enabled: true
6865
access_token: 'some-public-token'

Tests/Fixtures/app/AppKernel.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
<?php
22

3+
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
34
use Symfony\Component\HttpKernel\Kernel;
45
use Symfony\Component\Config\Loader\LoaderInterface;
6+
use SymfonyRollbarBundle\SymfonyRollbarBundle;
57

68
class AppKernel extends Kernel
79
{
810
public function registerBundles()
911
{
1012
$bundles = [
11-
new \Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
12-
new \SymfonyRollbarBundle\SymfonyRollbarBundle(),
13+
new FrameworkBundle(),
14+
new SymfonyRollbarBundle(),
1315
];
1416

1517
return $bundles;
@@ -23,6 +25,11 @@ public function getRootDir()
2325
return __DIR__;
2426
}
2527

28+
public function getProjectDir()
29+
{
30+
return $this->getRootDir();
31+
}
32+
2633
/**
2734
* @param \Symfony\Component\Config\Loader\LoaderInterface $loader
2835
*

Tests/Fixtures/app/config/config_test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ symfony_rollbar:
1010
- \ParseError
1111
- \Symfony\Component\HttpKernel\Exception\HttpExceptionInterface
1212
rollbar:
13+
transmit: false
1314
access_token: 'SOME_ROLLBAR_ACCESS_TOKEN_123456'
1415
environment: '%kernel.environment%'
1516
person_fn: \SymfonyRollbarBundle\Tests\Fixtures\PersonProvider

Tests/Fixtures/app/config/config_test_drb.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ symfony_rollbar:
99
- \SymfonyRollbarBundle\Tests\Fixtures\MyAwesomeException
1010
- \ParseError
1111
rollbar:
12+
transmit: false
1213
access_token: 'SOME_ROLLBAR_ACCESS_TOKEN_123456'
1314
environment: '%kernel.environment%'
1415

Tests/Fixtures/app/config/config_test_drbj.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ symfony_rollbar:
99
- \SymfonyRollbarBundle\Tests\Fixtures\MyAwesomeException
1010
- \ParseError
1111
rollbar:
12+
transmit: false
1213
access_token: 'SOME_ROLLBAR_ACCESS_TOKEN_123456'
1314
environment: '%kernel.environment%'
1415

0 commit comments

Comments
 (0)