Skip to content

Commit

Permalink
Merge pull request #24 from OxCom/develop
Browse files Browse the repository at this point in the history
Update rollbar configuration and fix few deprectaions
  • Loading branch information
OxCom authored May 28, 2019
2 parents 3989118 + a39a468 commit e157606
Show file tree
Hide file tree
Showing 24 changed files with 153 additions and 97 deletions.
35 changes: 0 additions & 35 deletions Command/AbstractCommand.php

This file was deleted.

44 changes: 41 additions & 3 deletions Command/DeployCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,58 @@

namespace SymfonyRollbarBundle\Command;

use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
* Class DeployCommand
*
* @package SymfonyRollbarBundle\Command
*/
class DeployCommand extends \SymfonyRollbarBundle\Command\AbstractCommand
class DeployCommand extends Command
{
protected static $defaultName = 'rollbar:deploy';

/**
* @var \Symfony\Component\Console\Style\SymfonyStyle
*/
protected $io;

/**
* @var \Symfony\Component\DependencyInjection\ContainerInterface
*/
protected $container;

/**
* DeployCommand constructor.
*
* @param \Symfony\Component\DependencyInjection\ContainerInterface $container
*/
public function __construct(ContainerInterface $container)
{
parent::__construct();

$this->container = $container;
}

/**
* Extend the initialize method to add additional parameters to the class.
*
* {@inheritdoc}
*/
public function initialize(InputInterface $input, OutputInterface $output)
{
parent::initialize($input, $output);

$io = new SymfonyStyle($input, $output);
$this->io = $io;
}

/**
* @inheritdoc
*/
Expand Down Expand Up @@ -65,9 +103,9 @@ protected function configure()
protected function execute(InputInterface $input, OutputInterface $output)
{
/** @var \SymfonyRollbarBundle\Provider\RollbarHandler $rbHandler */
$rbHandler = $this->getContainer()->get('symfony_rollbar.provider.rollbar_handler');
$rbHandler = $this->container->get('symfony_rollbar.provider.rollbar_handler');

$environment = $this->getContainer()->getParameter('kernel.environment');
$environment = $this->container->getParameter('kernel.environment');
$revision = $input->getArgument('revision');
$comment = $input->getOption('comment');
$rUser = $input->getOption('rollbar_username');
Expand Down
11 changes: 8 additions & 3 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ class Configuration implements ConfigurationInterface

const API_ENDPOINT = 'https://api.rollbar.com/api/1/';
const PHP_MAX_ITEMS = 10;
const MIN_OCCURRENCES_LEVEL = 0;

const VERBOSE = 'none';

const JS_ITEMS_PER_MINUTE = 60;
const JS_MAX_ITEMS = 0;
Expand Down Expand Up @@ -98,7 +101,6 @@ public function getConfigTreeBuilder()
->booleanNode('capture_error_stacktraces')->defaultTrue()->end()
->scalarNode('check_ignore')->defaultNull()->end()
->scalarNode('code_version')->defaultValue('')->end()
->booleanNode('enable_utf8_sanitization')->defaultTrue()->end()
->scalarNode('environment')->defaultValue(static::ENVIRONMENT)->end()
->arrayNode('custom')
->treatNullLike([])
Expand Down Expand Up @@ -159,8 +161,6 @@ public function getConfigTreeBuilder()
->end()
->scalarNode('scrub_whitelist')->defaultNull()->end()
->scalarNode('transformer')->defaultNull()->end()
->scalarNode('verbosity')->defaultValue(\Psr\Log\LogLevel::ERROR)->end()
->booleanNode('shift_function')->defaultTrue()->end()
->scalarNode('timeout')->defaultValue(static::TIMEOUT)->end()
->booleanNode('report_suppressed')->defaultFalse()->end()
->booleanNode('use_error_reporting')->defaultFalse()->end()
Expand All @@ -170,6 +170,11 @@ public function getConfigTreeBuilder()
->booleanNode('local_vars_dump')->defaultTrue()->end()
->scalarNode('max_nesting_depth')->defaultValue(-1)->end()
->scalarNode('max_items')->defaultValue(static::PHP_MAX_ITEMS)->end()
->booleanNode('log_payload')->defaultFalse()->end()
->booleanNode('raise_on_error')->defaultFalse()->end()
->booleanNode('transmit')->defaultTrue()->end()
->scalarNode('verbose')->defaultValue(static::VERBOSE)->end()
->scalarNode('minimum_level')->defaultValue(static::MIN_OCCURRENCES_LEVEL)->end()
->end()
->end()
->arrayNode('rollbar_js')->children()
Expand Down
9 changes: 7 additions & 2 deletions Provider/RollbarHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Monolog\Logger;
use Rollbar\Rollbar as RollbarNotifier;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpKernel\Kernel;
use SymfonyRollbarBundle\DependencyInjection\SymfonyRollbarExtension;
use Rollbar\Payload\Level;
use SymfonyRollbarBundle\Provider\Api\Filter;
Expand Down Expand Up @@ -121,9 +122,13 @@ protected function initialize()
$rConfig = $config['rollbar'];

// override specific values
$root = \method_exists($kernel, 'getProjectDir')
? $kernel->getProjectDir()
: $kernel->getRootDir();

$override = [
'root' => $kernel->getRootDir(),
'framework' => 'Symfony ' . \Symfony\Component\HttpKernel\Kernel::VERSION,
'root' => $root,
'framework' => 'Symfony ' . Kernel::VERSION,
];

foreach ($override as $key => $value) {
Expand Down
1 change: 1 addition & 0 deletions Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ services:

symfony_rollbar.command.deploy:
class: "%symfony_rollbar.command.deploy.class%"
arguments: ["@service_container"]
tags:
- {name: console.command, command: "rollbar:deploy"}

Expand Down
3 changes: 0 additions & 3 deletions Resources/doc/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ Simple configuration of bundle:
capture_error_stacktraces: true
check_ignore: null
code_version: ''
enable_utf8_sanitization': true
environment: 'production'
custom:
- {key: hello, value: world}
Expand Down Expand Up @@ -47,7 +46,6 @@ Simple configuration of bundle:
root: '%kernel.root_dir%'
scrub_fields: ['passwd', 'password', 'secret', 'confirm_password', 'password_confirmation', 'auth_token', 'csrf_token']
scrub_whitelist: null
shift_function': true
timeout: 3
report_suppressed: false
use_error_reporting: false
Expand All @@ -62,7 +60,6 @@ Simple configuration of bundle:
custom_truncation: null
ca_cert_path: null
transformer: null
verbosity: 'error'
rollbar_js:
enabled: true
access_token: 'some-public-token'
Expand Down
11 changes: 9 additions & 2 deletions Tests/Fixtures/app/AppKernel.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
<?php

use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Config\Loader\LoaderInterface;
use SymfonyRollbarBundle\SymfonyRollbarBundle;

class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = [
new \Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
new \SymfonyRollbarBundle\SymfonyRollbarBundle(),
new FrameworkBundle(),
new SymfonyRollbarBundle(),
];

return $bundles;
Expand All @@ -23,6 +25,11 @@ public function getRootDir()
return __DIR__;
}

public function getProjectDir()
{
return $this->getRootDir();
}

/**
* @param \Symfony\Component\Config\Loader\LoaderInterface $loader
*
Expand Down
1 change: 1 addition & 0 deletions Tests/Fixtures/app/config/config_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ symfony_rollbar:
- \ParseError
- \Symfony\Component\HttpKernel\Exception\HttpExceptionInterface
rollbar:
transmit: false
access_token: 'SOME_ROLLBAR_ACCESS_TOKEN_123456'
environment: '%kernel.environment%'
person_fn: \SymfonyRollbarBundle\Tests\Fixtures\PersonProvider
Expand Down
1 change: 1 addition & 0 deletions Tests/Fixtures/app/config/config_test_drb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ symfony_rollbar:
- \SymfonyRollbarBundle\Tests\Fixtures\MyAwesomeException
- \ParseError
rollbar:
transmit: false
access_token: 'SOME_ROLLBAR_ACCESS_TOKEN_123456'
environment: '%kernel.environment%'

Expand Down
1 change: 1 addition & 0 deletions Tests/Fixtures/app/config/config_test_drbj.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ symfony_rollbar:
- \SymfonyRollbarBundle\Tests\Fixtures\MyAwesomeException
- \ParseError
rollbar:
transmit: false
access_token: 'SOME_ROLLBAR_ACCESS_TOKEN_123456'
environment: '%kernel.environment%'

Expand Down
1 change: 1 addition & 0 deletions Tests/Fixtures/app/config/config_test_if.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ symfony_rollbar:
- \SymfonyRollbarBundle\Tests\Fixtures\MyAwesomeException
- \ParseError
rollbar:
transmit: false
access_token: 'SOME_ROLLBAR_ACCESS_TOKEN_123456'
environment: '%kernel.environment%'
person_fn: "get_awesome_person"
Expand Down
1 change: 1 addition & 0 deletions Tests/Fixtures/app/config/config_test_ifc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ symfony_rollbar:
- \SymfonyRollbarBundle\Tests\Fixtures\MyAwesomeException
- \ParseError
rollbar:
transmit: false
access_token: 'SOME_ROLLBAR_ACCESS_TOKEN_123456'
environment: '%kernel.environment%'
person_fn: "get_awesome_person"
Expand Down
1 change: 1 addition & 0 deletions Tests/Fixtures/app/config/config_test_is.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ symfony_rollbar:
- \SymfonyRollbarBundle\Tests\Fixtures\MyAwesomeException
- \ParseError
rollbar:
transmit: false
access_token: 'SOME_ROLLBAR_ACCESS_TOKEN_123456'
environment: '%kernel.environment%'
person_fn: "symfony_rollbar.fixture.person_provider"
Expand Down
1 change: 1 addition & 0 deletions Tests/Fixtures/app/config/config_test_p.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ symfony_rollbar:
- \SymfonyRollbarBundle\Tests\Fixtures\MyAwesomeException
- \ParseError
rollbar:
transmit: false
access_token: 'SOME_ROLLBAR_ACCESS_TOKEN_123456'
environment: '%kernel.environment%'
person:
Expand Down
1 change: 1 addition & 0 deletions Tests/Fixtures/app/config/config_test_pc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ symfony_rollbar:
- \SymfonyRollbarBundle\Tests\Fixtures\MyAwesomeException
- \ParseError
rollbar:
transmit: false
access_token: 'SOME_ROLLBAR_ACCESS_TOKEN_123456'
environment: '%kernel.environment%'
person:
Expand Down
8 changes: 5 additions & 3 deletions Tests/SymfonyRollbarBundle/Command/DeployCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ public function setUp()

public function testRegistration()
{
$container = static::$kernel->getContainer();
$application = new Application(static::$kernel);
$application->add(new DeployCommand());
$application->add(new DeployCommand($container));

try {
$application->find('rollbar:deploy');
Expand Down Expand Up @@ -71,7 +72,7 @@ public function testExecute($input, $expected, $message)
$container->set('symfony_rollbar.provider.api_client', $client);

$application = new Application(static::$kernel);
$application->add(new DeployCommand());
$application->add(new DeployCommand($container));

try {
$command = $application->find('rollbar:deploy');
Expand Down Expand Up @@ -112,8 +113,9 @@ public function generateExecuteInput()

public function testExecuteGeneric()
{
$container = static::$kernel->getContainer();
$application = new Application(static::$kernel);
$application->add(new DeployCommand());
$application->add(new DeployCommand($container));

$command = $application->find('rollbar:deploy');
$commandTester = new CommandTester($command);
Expand Down
Loading

0 comments on commit e157606

Please sign in to comment.