Skip to content

Commit 61e433c

Browse files
committed
Merge pull request #9 from stof/symfony_compat
Update the bundle to avoid deprecated APIs on symfony 2.6+
2 parents fcfb55f + 0b6376e commit 61e433c

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/DependencyInjection/KeenIOExtension.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
66
use Symfony\Component\DependencyInjection\ContainerBuilder;
77
use Symfony\Component\DependencyInjection\Definition;
8-
use KeenIO\Bundle\KeenIOBundle\DependencyInjection\Configuration;
98

109
class KeenIOExtension extends Extension
1110
{
@@ -24,8 +23,17 @@ public function load(array $configs, ContainerBuilder $container)
2423
$container->setParameter('keen_io.class', 'KeenIO\\Client\\KeenIOClient');
2524
$container->setParameter('keen_io_factory.class', 'KeenIO\\Client\\KeenIOClient');
2625

27-
$container->setDefinition('keen_io', new Definition('%keen_io.class%', array($arguments)))
28-
->setFactoryClass('%keen_io_factory.class%')
29-
->setFactoryMethod('factory');
26+
$definition = new Definition('%keen_io.class%', array($arguments));
27+
28+
if (method_exists($definition, 'setFactory')) {
29+
$definition->setFactory(array('%keen_io_factory.class%', 'factory'));
30+
} else {
31+
// BC layer for Symfony 2.5 and older
32+
$definition
33+
->setFactoryClass('%keen_io_factory.class%')
34+
->setFactoryMethod('factory');
35+
}
36+
37+
$container->setDefinition('keen_io', $definition);
3038
}
3139
}

0 commit comments

Comments
 (0)