Skip to content

Commit

Permalink
Symfony 4 Support (#64)
Browse files Browse the repository at this point in the history
* Symfony 4 support

* Updated collector template path

* Removed idea files

* Updated how we get container

* Fixed deprecated ConsoleExceptionEvent

* Removed idea files

* Removed stubborn idea file

* Made all m6 services public

* Removed test kernel class
  • Loading branch information
deluxetom authored and Oliboy50 committed Apr 14, 2018
1 parent 3b7ca45 commit 3e737c2
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 24 deletions.
8 changes: 2 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
language: php

php:
- 5.4
- 5.5
- 5.6
- 7.0
- 7.1
- 7.2

env:
- SYMFONY_VERSION=2.3.*
- SYMFONY_VERSION=2.7.*
- SYMFONY_VERSION=4.0.*

before_script:
- wget http://getcomposer.org/composer.phar
Expand Down
9 changes: 5 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"name": "m6web/statsd-bundle",
"description" : "Add statds metrics in your sf2 app. Allow you to bind metrics on any sf2 event.",
"description" : "Add statds metrics in your symfony app. Allow you to bind metrics on any symfony event.",
"type": "symfony-bundle",
"license": "MIT",
"version": "3.0.0",
"keywords": ["symfony", "bundle", "statsd", "m6web"],
"authors": [
{
Expand All @@ -16,13 +17,13 @@
"vendor-dir": "vendor"
},
"require": {
"php": ">=5.4.0",
"symfony/property-access" : ">=2.2",
"php": "^7.1.3",
"symfony/property-access": "^4.0",
"m6web/statsd": "^1.3"
},
"require-dev": {
"atoum/atoum": "^2.8|^3.0",
"symfony/symfony": "~2.3|~3.0",
"symfony/symfony": "~4.0",
"m6web/coke" : "~1.2",
"m6web/symfony2-coding-standard" : "~1.2"
},
Expand Down
6 changes: 4 additions & 2 deletions src/DependencyInjection/M6WebStatsdExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ public function load(array $configs, ContainerBuilder $container)
}
if ($container->getParameter('kernel.debug')) {
$definition = new Definition('M6Web\Bundle\StatsdBundle\DataCollector\StatsdDataCollector');

$definition->setPublic(true);
$definition->addTag(
'data_collector',
[
'template' => 'M6WebStatsdBundle:Collector:statsd',
'template' => '@M6WebStatsd/Collector/statsd.html.twig',
'id' => 'statsd'
]
);
Expand Down Expand Up @@ -153,6 +153,7 @@ protected function loadClient($container, $alias, array $config, array $servers,
// Add the statsd client configured
$serviceId = ($alias == 'default') ? 'm6_statsd' : 'm6_statsd.'.$alias;
$definition = new Definition('M6Web\Bundle\StatsdBundle\Client\Client');
$definition->setPublic(true);
$definition->addArgument($usedServers);

if (isset($config['to_send_limit'])) {
Expand All @@ -171,6 +172,7 @@ protected function loadClient($container, $alias, array $config, array $servers,
// Add the statsd client listener
$serviceListenerId = $serviceId.'.listener';
$definition = new Definition('M6Web\Bundle\StatsdBundle\Statsd\Listener');
$definition->setPublic(true);
$definition->addArgument(new Reference($serviceId));
$definition->addArgument(new Reference('event_dispatcher'));
$definition->addTag('kernel.event_listener', [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

namespace M6Web\Bundle\StatsdBundle\Event;

use Symfony\Component\Console\Event\ConsoleExceptionEvent as BaseEvent;
use Symfony\Component\Console\Event\ConsoleErrorEvent as BaseEvent;
use Symfony\Component\Console\Event\ConsoleEvent as BaseConsoleEvent;

/**
* Triggered on console exception
*/
class ConsoleExceptionEvent extends ConsoleEvent
class ConsoleErrorEvent extends ConsoleEvent
{
/**
* {@inheritDoc}
Expand Down
10 changes: 8 additions & 2 deletions src/M6WebStatsdBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace M6Web\Bundle\StatsdBundle;

use M6Web\Bundle\StatsdBundle\DependencyInjection\M6WebStatsdExtension;
use Symfony\Component\DependencyInjection\Extension\ExtensionInterface;
use Symfony\Component\HttpKernel\Bundle\Bundle;

/**
Expand All @@ -13,10 +15,14 @@ class M6WebStatsdBundle extends Bundle
* trick allowing bypassing the Bundle::getContainerExtension check on getAlias
* not very clean, to investigate
*
* @return Object DependencyInjection\M6WebStatsdExtension
* @return M6WebStatsdExtension|ExtensionInterface
*/
public function getContainerExtension()
{
return new DependencyInjection\M6WebStatsdExtension();
if (null === $this->extension) {
$this->extension = new M6WebStatsdExtension();
}

return $this->extension;
}
}
4 changes: 2 additions & 2 deletions src/Resources/views/Collector/statsd.html.twig
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% extends 'WebProfilerBundle:Profiler:layout.html.twig' %}
{% extends '@WebProfiler/Profiler/layout.html.twig' %}

{% block toolbar %}
{% set icon %}
Expand All @@ -10,7 +10,7 @@
<span>{{ collector.operations }}</span>
</div>
{% endset %}
{% include 'WebProfilerBundle:Profiler:toolbar_item.html.twig' with { 'link': true } %}
{% include '@WebProfiler/Profiler/toolbar_item.html.twig' with { 'link': true } %}
{% endblock %}

{% block head %}
Expand Down
5 changes: 1 addition & 4 deletions src/Tests/Units/DependencyInjection/M6WebStatsdExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use M6Web\Bundle\StatsdBundle\DependencyInjection\M6WebStatsdExtension as BaseM6WebStatsdExtension;
use Symfony\Component\EventDispatcher\EventDispatcher;


class M6WebStatsdExtension extends atoum\test
{

Expand All @@ -22,9 +21,7 @@ protected function initContainer($resource, $debug = false)
$this->container = new ContainerBuilder();
$this->container->register('event_dispatcher', new EventDispatcher());
$this->container->registerExtension(new BaseM6WebStatsdExtension());

$this->loadConfiguration($this->container, $resource);

$this->container->setParameter('kernel.debug', $debug);
$this->container->compile();
}
Expand Down Expand Up @@ -101,4 +98,4 @@ public function shellPatternConfigDataProvider()

];
}
}
}
4 changes: 2 additions & 2 deletions src/Tests/Units/Listener/ConsoleListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ public function eventDataProvider()
],
[
'onException',
new \Symfony\Component\Console\Event\ConsoleExceptionEvent($command, $input, $output, $exception, 0),
new \Symfony\Component\Console\Event\ConsoleErrorEvent($input, $output, $exception, $command),
[
[
'name' => ConsoleEvent::EXCEPTION,
'class' =>'M6Web\Bundle\StatsdBundle\Event\ConsoleExceptionEvent'
'class' => 'M6Web\Bundle\StatsdBundle\Event\ConsoleErrorEvent'
]
]
],
Expand Down

0 comments on commit 3e737c2

Please sign in to comment.