Skip to content

Commit 3e737c2

Browse files
deluxetomOliboy50
authored andcommitted
Symfony 4 Support (#64)
* 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
1 parent 3b7ca45 commit 3e737c2

8 files changed

Lines changed: 26 additions & 24 deletions

File tree

.travis.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
language: php
22

33
php:
4-
- 5.4
5-
- 5.5
6-
- 5.6
7-
- 7.0
84
- 7.1
5+
- 7.2
96

107
env:
11-
- SYMFONY_VERSION=2.3.*
12-
- SYMFONY_VERSION=2.7.*
8+
- SYMFONY_VERSION=4.0.*
139

1410
before_script:
1511
- wget http://getcomposer.org/composer.phar

composer.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
{
22
"name": "m6web/statsd-bundle",
3-
"description" : "Add statds metrics in your sf2 app. Allow you to bind metrics on any sf2 event.",
3+
"description" : "Add statds metrics in your symfony app. Allow you to bind metrics on any symfony event.",
44
"type": "symfony-bundle",
55
"license": "MIT",
6+
"version": "3.0.0",
67
"keywords": ["symfony", "bundle", "statsd", "m6web"],
78
"authors": [
89
{
@@ -16,13 +17,13 @@
1617
"vendor-dir": "vendor"
1718
},
1819
"require": {
19-
"php": ">=5.4.0",
20-
"symfony/property-access" : ">=2.2",
20+
"php": "^7.1.3",
21+
"symfony/property-access": "^4.0",
2122
"m6web/statsd": "^1.3"
2223
},
2324
"require-dev": {
2425
"atoum/atoum": "^2.8|^3.0",
25-
"symfony/symfony": "~2.3|~3.0",
26+
"symfony/symfony": "~4.0",
2627
"m6web/coke" : "~1.2",
2728
"m6web/symfony2-coding-standard" : "~1.2"
2829
},

src/DependencyInjection/M6WebStatsdExtension.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ public function load(array $configs, ContainerBuilder $container)
4444
}
4545
if ($container->getParameter('kernel.debug')) {
4646
$definition = new Definition('M6Web\Bundle\StatsdBundle\DataCollector\StatsdDataCollector');
47-
47+
$definition->setPublic(true);
4848
$definition->addTag(
4949
'data_collector',
5050
[
51-
'template' => 'M6WebStatsdBundle:Collector:statsd',
51+
'template' => '@M6WebStatsd/Collector/statsd.html.twig',
5252
'id' => 'statsd'
5353
]
5454
);
@@ -153,6 +153,7 @@ protected function loadClient($container, $alias, array $config, array $servers,
153153
// Add the statsd client configured
154154
$serviceId = ($alias == 'default') ? 'm6_statsd' : 'm6_statsd.'.$alias;
155155
$definition = new Definition('M6Web\Bundle\StatsdBundle\Client\Client');
156+
$definition->setPublic(true);
156157
$definition->addArgument($usedServers);
157158

158159
if (isset($config['to_send_limit'])) {
@@ -171,6 +172,7 @@ protected function loadClient($container, $alias, array $config, array $servers,
171172
// Add the statsd client listener
172173
$serviceListenerId = $serviceId.'.listener';
173174
$definition = new Definition('M6Web\Bundle\StatsdBundle\Statsd\Listener');
175+
$definition->setPublic(true);
174176
$definition->addArgument(new Reference($serviceId));
175177
$definition->addArgument(new Reference('event_dispatcher'));
176178
$definition->addTag('kernel.event_listener', [
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
namespace M6Web\Bundle\StatsdBundle\Event;
44

5-
use Symfony\Component\Console\Event\ConsoleExceptionEvent as BaseEvent;
5+
use Symfony\Component\Console\Event\ConsoleErrorEvent as BaseEvent;
66
use Symfony\Component\Console\Event\ConsoleEvent as BaseConsoleEvent;
77

88
/**
99
* Triggered on console exception
1010
*/
11-
class ConsoleExceptionEvent extends ConsoleEvent
11+
class ConsoleErrorEvent extends ConsoleEvent
1212
{
1313
/**
1414
* {@inheritDoc}

src/M6WebStatsdBundle.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace M6Web\Bundle\StatsdBundle;
44

5+
use M6Web\Bundle\StatsdBundle\DependencyInjection\M6WebStatsdExtension;
6+
use Symfony\Component\DependencyInjection\Extension\ExtensionInterface;
57
use Symfony\Component\HttpKernel\Bundle\Bundle;
68

79
/**
@@ -13,10 +15,14 @@ class M6WebStatsdBundle extends Bundle
1315
* trick allowing bypassing the Bundle::getContainerExtension check on getAlias
1416
* not very clean, to investigate
1517
*
16-
* @return Object DependencyInjection\M6WebStatsdExtension
18+
* @return M6WebStatsdExtension|ExtensionInterface
1719
*/
1820
public function getContainerExtension()
1921
{
20-
return new DependencyInjection\M6WebStatsdExtension();
22+
if (null === $this->extension) {
23+
$this->extension = new M6WebStatsdExtension();
24+
}
25+
26+
return $this->extension;
2127
}
2228
}

src/Resources/views/Collector/statsd.html.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{% extends 'WebProfilerBundle:Profiler:layout.html.twig' %}
1+
{% extends '@WebProfiler/Profiler/layout.html.twig' %}
22

33
{% block toolbar %}
44
{% set icon %}
@@ -10,7 +10,7 @@
1010
<span>{{ collector.operations }}</span>
1111
</div>
1212
{% endset %}
13-
{% include 'WebProfilerBundle:Profiler:toolbar_item.html.twig' with { 'link': true } %}
13+
{% include '@WebProfiler/Profiler/toolbar_item.html.twig' with { 'link': true } %}
1414
{% endblock %}
1515

1616
{% block head %}

src/Tests/Units/DependencyInjection/M6WebStatsdExtension.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
use M6Web\Bundle\StatsdBundle\DependencyInjection\M6WebStatsdExtension as BaseM6WebStatsdExtension;
99
use Symfony\Component\EventDispatcher\EventDispatcher;
1010

11-
1211
class M6WebStatsdExtension extends atoum\test
1312
{
1413

@@ -22,9 +21,7 @@ protected function initContainer($resource, $debug = false)
2221
$this->container = new ContainerBuilder();
2322
$this->container->register('event_dispatcher', new EventDispatcher());
2423
$this->container->registerExtension(new BaseM6WebStatsdExtension());
25-
2624
$this->loadConfiguration($this->container, $resource);
27-
2825
$this->container->setParameter('kernel.debug', $debug);
2926
$this->container->compile();
3027
}
@@ -101,4 +98,4 @@ public function shellPatternConfigDataProvider()
10198

10299
];
103100
}
104-
}
101+
}

src/Tests/Units/Listener/ConsoleListener.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,11 @@ public function eventDataProvider()
6565
],
6666
[
6767
'onException',
68-
new \Symfony\Component\Console\Event\ConsoleExceptionEvent($command, $input, $output, $exception, 0),
68+
new \Symfony\Component\Console\Event\ConsoleErrorEvent($input, $output, $exception, $command),
6969
[
7070
[
7171
'name' => ConsoleEvent::EXCEPTION,
72-
'class' =>'M6Web\Bundle\StatsdBundle\Event\ConsoleExceptionEvent'
72+
'class' => 'M6Web\Bundle\StatsdBundle\Event\ConsoleErrorEvent'
7373
]
7474
]
7575
],

0 commit comments

Comments
 (0)