From 365c8221a554935841e6f599d1ecbc32e636612c Mon Sep 17 00:00:00 2001 From: D Vargas Date: Wed, 4 Sep 2019 12:35:52 +0200 Subject: [PATCH] OPENEUROPA-1739: Ensure Yaml::DUMP_EXCEPTION_ON_INVALID_TYPE exists by requiring simfony/yaml >=3.1. --- composer.json | 6 +++++- src/Commands/AbstractDrupalCommands.php | 9 +-------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/composer.json b/composer.json index d3094f1c..5d054928 100644 --- a/composer.json +++ b/composer.json @@ -10,12 +10,16 @@ "consolidation/robo": "^1.4", "gitonomy/gitlib": "^1.0", "nuvoleweb/robo-config": "^0.2.1", - "jakeasmith/http_build_url": "^1.0.1" + "jakeasmith/http_build_url": "^1.0.1", + "symfony/yaml": ">=3.1" }, "require-dev": { "openeuropa/code-review": "~1.0.0-beta3", "phpunit/phpunit": "~5.5||~6.0" }, + "_readme": [ + "We need require a version of 'symfony/yaml' equal or higher then '3.1' since versions before don't have dumper 'DUMP' constants available." + ], "autoload": { "psr-4": { "OpenEuropa\\TaskRunner\\": "./src/" diff --git a/src/Commands/AbstractDrupalCommands.php b/src/Commands/AbstractDrupalCommands.php index e4e18d65..a62df16e 100644 --- a/src/Commands/AbstractDrupalCommands.php +++ b/src/Commands/AbstractDrupalCommands.php @@ -341,14 +341,7 @@ public function servicesSetup(array $options = [ // Read given parameters. $service_parameters['parameters'] = $this->getConfig()->get('drupal.service_parameters'); $dumper = new Dumper(2); - // Set flag to be compatible with symfony/yaml versions 2.x.x. (see https://github.com/symfony/yaml/blob/2.8/Dumper.php#L53) - if (property_exists(Yaml::class, 'DUMP_EXCEPTION_ON_INVALID_TYPE')) { - $flag = Yaml::DUMP_EXCEPTION_ON_INVALID_TYPE; - } else { - $flag = true; - } - - $yaml = $dumper->dump($service_parameters, PHP_INT_MAX, 0, $flag); + $yaml = $dumper->dump($service_parameters, PHP_INT_MAX, 0, Yaml::DUMP_EXCEPTION_ON_INVALID_TYPE); // Set the destination file. $services_destination_file = $options['root'] . '/sites/' . $options['sites-subdir'] . '/services.yml';