Skip to content

Commit

Permalink
Merge pull request #153 from liip/cordoval-symfony-40
Browse files Browse the repository at this point in the history
Symfony 4.0
  • Loading branch information
lsmith77 authored Dec 1, 2017
2 parents 3ef9b66 + 3521f6e commit 0033105
Show file tree
Hide file tree
Showing 12 changed files with 68 additions and 44 deletions.
13 changes: 7 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,9 @@ sudo: required
dist: trusty
group: edge
php:
- 5.4
- 5.5
- 5.6
- 7.0
- 7.1
- hhvm

cache:
directories:
Expand All @@ -19,8 +16,6 @@ env:

matrix:
include:
- php: 5.6
env: SYMFONY_VERSION=2.3
- php: 5.6
env: SYMFONY_VERSION=2.8
- php: 5.6
Expand All @@ -29,8 +24,14 @@ matrix:
env: SYMFONY_VERSION=3.1
- php: 5.6
env: SYMFONY_VERSION=3.2
- php: 5.6
env: SYMFONY_VERSION=^3.3
- php: 5.6
env: SYMFONY_VERSION=^3.4
- php: 7.1
env: SYMFONY_VERSION=^4.0
- php: 5.4
env: SYMFONY_VERSION=2.3;COMPOSER_FLAGS="--prefer-lowest"
env: SYMFONY_VERSION=2.7;COMPOSER_FLAGS="--prefer-lowest"

before_install:
- if [[ $TRAVIS_PHP_VERSION != '7.0' && $TRAVIS_PHP_VERSION != '7.1' && $TRAVIS_PHP_VERSION != 'hhvm' ]]; then phpenv config-rm xdebug.ini; fi
Expand Down
12 changes: 12 additions & 0 deletions DependencyInjection/LiipMonitorExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,18 @@ public function load(array $configs, ContainerBuilder $container)

$container->setParameter(sprintf('%s.default_group', $this->getAlias()), $config['default_group']);

// symfony3 does not define templating.helper.assets unless php templating is included
if ($container->has('templating.helper.assets')) {
$pathHelper = $container->getDefinition('liip_monitor.helper');
$pathHelper->replaceArgument(0, 'templating.helper.assets');
}

// symfony3 does not define templating.helper.router unless php templating is included
if ($container->has('templating.helper.router')) {
$pathHelper = $container->getDefinition('liip_monitor.helper');
$pathHelper->replaceArgument(1, 'templating.helper.router');
}

if (empty($config['checks'])) {
return;
}
Expand Down
16 changes: 3 additions & 13 deletions Helper/PathHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,15 @@

namespace Liip\MonitorBundle\Helper;

use Symfony\Component\DependencyInjection\ContainerInterface;

class PathHelper
{
protected $assetsHelper;
protected $routerHelper;

/**
* @param ContainerInterface $container
*/
public function __construct(ContainerInterface $container)
public function __construct($assetsHelper, $routerHelper)
{
// symfony3 does not define templating.helper.assets unless php templating is included
$this->assetsHelper = $container->has('templating.helper.assets') ?
$container->get('templating.helper.assets') : $container->get('assets.packages');

// symfony3 does not define templating.helper.router unless php templating is included
$this->routerHelper = $container->has('templating.helper.router') ?
$container->get('templating.helper.router') : $container->get('router');
$this->assetsHelper = $assetsHelper;
$this->routerHelper = $routerHelper;
}

/**
Expand Down
4 changes: 0 additions & 4 deletions Resources/config/controller.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,9 @@

<parameters>
<parameter key="liip_monitor.health_controller.class">Liip\MonitorBundle\Controller\HealthCheckController</parameter>
<parameter key="liip_monitor.helper.class">Liip\MonitorBundle\Helper\PathHelper</parameter>
</parameters>

<services>
<service id="liip_monitor.helper" class="%liip_monitor.helper.class%">
<argument type="service" id="service_container" />
</service>
<service id="liip_monitor.health_controller" class="%liip_monitor.health_controller.class%">
<argument type="service" id="liip_monitor.helper.runner_manager" />
<argument type="service" id="liip_monitor.helper" />
Expand Down
5 changes: 5 additions & 0 deletions Resources/config/helper.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,14 @@
<parameter key="liip_monitor.helper.raw_console_reporter.class">Liip\MonitorBundle\Helper\RawConsoleReporter</parameter>
<parameter key="liip_monitor.helper.console_reporter.class">Liip\MonitorBundle\Helper\ConsoleReporter</parameter>
<parameter key="liip_monitor.helper.runner_manager.class">Liip\MonitorBundle\Helper\RunnerManager</parameter>
<parameter key="liip_monitor.helper.class">Liip\MonitorBundle\Helper\PathHelper</parameter>
</parameters>

<services>
<service id="liip_monitor.helper" class="%liip_monitor.helper.class%">
<argument type="service" id="assets.packages" />
<argument type="service" id="router" />
</service>
<service id="liip_monitor.helper.raw_console_reporter" class="%liip_monitor.helper.raw_console_reporter.class%" />
<service id="liip_monitor.helper.console_reporter" class="%liip_monitor.helper.console_reporter.class%" />

Expand Down
19 changes: 11 additions & 8 deletions Tests/Helper/PathHelperTest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

namespace Liip\MonitorBundle\Tests\Helper;

use Liip\MonitorBundle\Helper\PathHelper;
Expand All @@ -7,19 +8,21 @@

class PathHelperTest extends WebTestCase
{
public function testGenerateRoutes()
static public function getKernelClass()
{
if (Kernel::MAJOR_VERSION === '2' && Kernel::MINOR_VERSION === '7') {
$environment = 'symfony27';
} else {
$environment = 'symfony' . Kernel::MAJOR_VERSION;
}
require_once __DIR__.'/../app/AppKernel.php';

return 'AppKernel';
}

public function testGenerateRoutes()
{
$environment = 'symfony' . Kernel::MAJOR_VERSION;
$client = static::createClient(array('environment' => $environment));

$container = $client->getContainer();
$container = $client->getKernel()->getContainer();

$pathHelper = new PathHelper($container);
$pathHelper = $container->get('path_helper');

// test route is defined in Tests/app/routing.yml
$routes = $pathHelper->generateRoutes(['test_route' => []]);
Expand Down
1 change: 1 addition & 0 deletions Tests/app/AppKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public function registerBundles()
return [
new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
new Symfony\Bundle\TwigBundle\TwigBundle(),
new Liip\MonitorBundle\LiipMonitorBundle(),
];
}

Expand Down
6 changes: 4 additions & 2 deletions Tests/app/config_symfony2.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# symfony 2 config (requires assets_base_urls for testing)
imports:
- { resource: services.yml }

# symfony 2.7 config (no longer allows assets_base_urls)
framework:
router:
resource: "%kernel.root_dir%/routing.yml"
secret: test
templating:
engines: ['twig']
assets_base_urls: { http: ["http://testurl"], ssl: ["http://testurl"] }
test: ~
profiler:
collect: false
3 changes: 3 additions & 0 deletions Tests/app/config_symfony3.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
imports:
- { resource: services.yml }

# symfony 3 config (requires assets defined)
framework:
router:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
# symfony 2.7 config (no longer allows assets_base_urls)
imports:
- { resource: services.yml }

# symfony 3 config (requires assets defined)
framework:
router:
resource: "%kernel.root_dir%/routing.yml"
secret: test
templating:
engines: ['twig']
test: ~
assets: ~
profiler:
collect: false
4 changes: 4 additions & 0 deletions Tests/app/services.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
services:
path_helper:
alias: 'liip_monitor.helper'
public: true
23 changes: 13 additions & 10 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,28 @@
"homepage": "https://github.com/liip/LiipMonitorBundle/contributors"
}
],
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"php": "^5.4|^7.0",
"symfony/framework-bundle": "~2.3|~3.0",
"zendframework/zenddiagnostics": "^1.0.2"
"symfony/framework-bundle": "~2.7|~3.0|^4.0",
"zendframework/zenddiagnostics": "^1.0.2",
"symfony/symfony": "^4.0"
},
"require-dev": {
"matthiasnoback/symfony-dependency-injection-test": "^0.7.4",
"matthiasnoback/symfony-dependency-injection-test": "^1.0",
"sensiolabs/security-checker": "~1.3|~2.0|~3.0|~4.0",
"guzzlehttp/guzzle": "~3.8|~4.0|~5.0|~6.0",
"symfony/expression-language": "~2.3|~3.0",
"symfony/expression-language": "~2.3|~3.0|^4.0",
"swiftmailer/swiftmailer": "~5.4",
"doctrine/migrations": "~1.0",
"doctrine/doctrine-migrations-bundle": "~1.0",
"symfony/twig-bundle": "^2.0|^3.0",
"symfony/browser-kit": "^2.0|^3.0",
"symfony/asset": "^2.0|^3.0",
"symfony/templating": "^2.0|^3.0",
"phpunit/phpunit": "^4.8|^5.0",
"symfony/finder": "^2.0|^3.0"
"symfony/twig-bundle": "^2.0|^3.0|^4.0",
"symfony/browser-kit": "^2.0|^3.0|^4.0",
"symfony/asset": "^2.0|^3.0|^4.0",
"symfony/templating": "^2.0|^3.0|^4.0",
"phpunit/phpunit": "^4.0|^5.0",
"symfony/finder": "^2.0|^3.0|^4.0"
},
"suggest": {
"sensio/distribution-bundle": "To be able to use the composer ScriptHandler",
Expand Down

0 comments on commit 0033105

Please sign in to comment.