Skip to content

Commit

Permalink
Merge pull request #19 from stof/symfony_3
Browse files Browse the repository at this point in the history
Add support for Symfony 3
  • Loading branch information
henrikbjorn authored Feb 21, 2017
2 parents f9f5f18 + 80d34ef commit 1159bf3
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 15 deletions.
30 changes: 28 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,32 @@ language: php
php:
- 5.3
- 5.4
- 5.5
- 5.6
- 7.0
- 7.1
- nightly

before_script:
- composer install --dev
matrix:
include:
- php: 5.3
env: COMPOSER_FLAGS='--prefer-lowest --prefer-stable' SYMFONY_DEPRECATIONS_HELPER=weak
- php: 7.1
env: DEPENDENCIES=dev SYMFONY_DEPRECATIONS_HELPER=weak
# Test against LTS versions
- php: 7.0
env: SYMFONY_VERSION=2.8.*
allow_failures:
- php: nightly

sudo: false

cache:
directories:
- $HOME/.composer/cache/files

before_install:
- if [ "$SYMFONY_VERSION" != "" ]; then composer require "symfony/symfony:${SYMFONY_VERSION}" --no-update; fi;
- if [ "$DEPENDENCIES" = "dev" ]; then perl -pi -e 's/^}$/,"minimum-stability":"dev"}/' composer.json; fi;

install: composer update --prefer-dist $COMPOSER_FLAGS
15 changes: 12 additions & 3 deletions DependencyInjection/HBStampieExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace HB\StampieBundle\DependencyInjection;

use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\ChildDefinition;
use Symfony\Component\DependencyInjection\DefinitionDecorator;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\Config\FileLocator;
Expand All @@ -25,7 +26,7 @@ class HBStampieExtension extends \Symfony\Component\HttpKernel\DependencyInjecti
{
public function load(array $configs, ContainerBuilder $container)
{
$loader = new XmlFileLoader($container, new Filelocator(__DIR__ . '/../Resources/config'));
$loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader->load('config.xml');

$processor = new Processor();
Expand All @@ -42,15 +43,23 @@ public function load(array $configs, ContainerBuilder $container)
throw new \InvalidArgumentException(sprintf('Invalid mailer "%s" specified', $config['mailer']));
}

if (class_exists('Symfony\Component\DependencyInjection\ChildDefinition')) {
$definition = new ChildDefinition($mailerServiceId);
} else {
$definition = new DefinitionDecorator($mailerServiceId);
}

// get the abstract definition of an mailer and create "hb_stampie" based on it
$container
->setDefinition('hb_stampie.mailer.real', new DefinitionDecorator($mailerServiceId))
$definition
->setPublic(false)
->setArguments(array(
$container->getDefinition($adapterServiceId),
$config['server_token'],
))
;

$container->setDefinition('hb_stampie.mailer.real', $definition);

$mailerId = 'hb_stampie.mailer.real';

if (isset($config['extra'])) {
Expand Down
6 changes: 2 additions & 4 deletions Resources/config/extra.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,12 @@
These are removed by the DI extension when they should not be activated.
-->
<service id="hb_stampie.extra.listener.impersonate" class="%hb_stampie.extra.listener.impersonate.class%">
<!-- TODO switch to the kernel.event_subscriber tag when dropping the 2.0 support. -->
<tag name="kernel.event_listener" event="stampie.pre_send" method="preSend" />
<tag name="kernel.event_subscriber" />
<argument /><!-- delivery address -->
</service>

<service id="hb_stampie.listener.message_logger" class="%hb_stampie.listener.message_logger.class%">
<!-- TODO switch to the kernel.event_subscriber tag when dropping the 2.0 support. -->
<tag name="kernel.event_listener" event="stampie.pre_send" method="preSend" />
<tag name="kernel.event_subscriber" />
</service>
</services>
</container>
5 changes: 4 additions & 1 deletion Tests/DependencyInjection/HBStampieExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
*/
class HBStampieExtensionTest extends \PHPUnit_Framework_TestCase
{
public function setUp()
/** @var HBStampieExtension */
private $extension;

protected function setUp()
{
$this->extension = new HBStampieExtension();
}
Expand Down
11 changes: 6 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "henrikbjorn/stampie-bundle",
"description": "This bundle provides integration for Stampie Email Library",
"keywords": ["symfony2", "stampie", "email"],
"keywords": ["symfony", "stampie", "email"],
"type": "symfony-bundle",
"license": "MIT",
"authors": [{
Expand All @@ -10,12 +10,13 @@
}],
"require": {
"php" : ">=5.3.3",
"symfony/framework-bundle" : "~2.0",
"symfony/console" : "~2.0",
"henrikbjorn/stampie" : "~0.6"
"symfony/framework-bundle" : "^2.7 || ^3.0",
"symfony/console" : "^2.7 || ^3.0",
"henrikbjorn/stampie" : "~0.11"
},
"require-dev": {
"stof/stampie-extra": "~0.2@dev"
"stof/stampie-extra": "~0.2@dev",
"symfony/phpunit-bridge": "^3.2"
},
"suggest": {
"stof/stampie-extra": "to have event-based hooks in the mailer"
Expand Down

0 comments on commit 1159bf3

Please sign in to comment.