Skip to content

Commit

Permalink
Merge pull request #19 from mcg-web/support_symfony_4_2
Browse files Browse the repository at this point in the history
Support symfony 4.2
  • Loading branch information
mcg-web authored Dec 7, 2018
2 parents a1deeca + d3cdd11 commit c063b35
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 18 deletions.
26 changes: 14 additions & 12 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ dist: trusty
sudo: false

git:
depth: 1
depth: 50

branches:
only:
Expand All @@ -26,31 +26,33 @@ matrix:
env: SYMFONY_VERSION=3.4.*
- php: 7.2
env: SYMFONY_VERSION=3.2.* TEST_COVERAGE=true
- php: 7.2
env: SYMFONY_VERSION=4.1.* DEPENDENCIES=dev
- php: 7.3
env: SYMFONY_VERSION=4.1.*
- php: 7.3
env: SYMFONY_VERSION=4.2.*
- php: nightly
env: COMPOSER_UPDATE_FLAGS=--ignore-platform-reqs
allow_failures:
- php: nightly
- php: 7.2
env: SYMFONY_VERSION=4.1.* DEPENDENCIES=dev
cache:
directories:
- $HOME/.composer/cache
- $HOME/.php_cs.cache
- vendor/

before_install:
- if [ ${DEPENDENCIES} = "dev" ]; then perl -pi -e 's/^}$/,"minimum-stability":"dev"}/' composer.json; fi;
- if [[ ${TEST_COVERAGE} != true ]]; then phpenv config-rm xdebug.ini || true; fi
- if [ "${DEPENDENCIES}" = "dev" ]; then perl -pi -e 's/^}$/,"minimum-stability":"dev"}/' composer.json; fi;
- if [[ "${TEST_COVERAGE}" != "true" ]]; then phpenv config-rm xdebug.ini || true; fi
- composer selfupdate
- if [ "$SYMFONY_VERSION" != "" ]; then composer require "symfony/symfony:${SYMFONY_VERSION}" --dev --no-update; fi;
# disable default memory limit
- export INI=~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
- echo memory_limit = -1 >> $INI

install: composer update --prefer-source --no-interaction --optimize-autoloader ${COMPOSER_UPDATE_FLAGS}
install: travis_retry composer update --prefer-source --no-interaction --optimize-autoloader ${COMPOSER_UPDATE_FLAGS}

script:
- bin/phpunit --debug $( if [ $TEST_COVERAGE = true ]; then echo "-d xdebug.max_nesting_level=1000 --coverage-clover=build/logs/clover.xml"; fi; )
- if [ ${PHP_CS_FIXER} = true ]; then composer require "friendsofphp/php-cs-fixer:^2.0" && bin/php-cs-fixer fix --diff --dry-run -v; fi;
- bin/phpunit --debug $( if [ "$TEST_COVERAGE" = "true" ]; then echo "-d xdebug.max_nesting_level=1000 --coverage-clover=build/logs/clover.xml"; fi; )
- if [ "${PHP_CS_FIXER}" = "true" ]; then composer require "friendsofphp/php-cs-fixer:^2.0" && bin/php-cs-fixer fix --diff --dry-run -v; fi;

after_script:
- if [ ${TEST_COVERAGE} = true ]; then composer require "satooshi/php-coveralls:^1.0" && travis_retry php bin/coveralls -v; fi
- if [ "${TEST_COVERAGE}" = "true" ]; then composer require "satooshi/php-coveralls:^1.0" && travis_retry php bin/coveralls -v; fi
31 changes: 25 additions & 6 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace Overblog\DataLoaderBundle\DependencyInjection;

use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;

Expand All @@ -21,10 +22,13 @@ class Configuration implements ConfigurationInterface

public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('overblog_dataloader');
$treeBuilder = new TreeBuilder('overblog_dataloader');

// BC layer for symfony/config 4.1 and older
$rootNode = self::getRootNodeWithoutDeprecation($treeBuilder, 'overblog_dataloader');
$rootNode
->children()
->scalarNode('factory')->end()
->arrayNode('defaults')
->isRequired()
->addDefaultsIfNotSet()
Expand Down Expand Up @@ -61,8 +65,8 @@ public function getConfigTreeBuilder()

private function addOptionsSection()
{
$builder = new TreeBuilder();
$node = $builder->root('options');
$builder = new TreeBuilder('options');
$node = self::getRootNodeWithoutDeprecation($builder, 'options');
$node
->children()
->booleanNode('batch')->defaultTrue()->end()
Expand All @@ -77,8 +81,8 @@ private function addOptionsSection()

private function addCallableSection($name)
{
$builder = new TreeBuilder();
$node = $builder->root($name, 'scalar');
$builder = new TreeBuilder($name, 'scalar');
$node = self::getRootNodeWithoutDeprecation($builder, $name, 'scalar');

$node
->validate()
Expand All @@ -99,4 +103,19 @@ private function addCallableSection($name)

return $node;
}

/**
* @internal
*
* @param TreeBuilder $builder
* @param string|null $name
* @param string $type
*
* @return ArrayNodeDefinition|\Symfony\Component\Config\Definition\Builder\NodeDefinition
*/
public static function getRootNodeWithoutDeprecation(TreeBuilder $builder, $name, $type = 'array')
{
// BC layer for symfony/config 4.1 and older
return \method_exists($builder, 'getRootNode') ? $builder->getRootNode() : $builder->root($name, $type);
}
}

0 comments on commit c063b35

Please sign in to comment.