Skip to content

Commit 87fb45f

Browse files
author
Dustin Wheeler
committed
Resolve YAML::parse deprecation notice.
See igorw/ConfigServiceProvider#46 When the above PR is merged, we can revert this commit. The current code is throwing errors in the test suite due to deprecation notices from Yaml::parse. We haven't upgraded this package so no idea why we started getting notices like this but it is what it is. Parse method now triggers a warning if you give it a path. It expects the yaml file contents, not a path. This patch adds a provider that extends Igor's and makes this change. We then sub this provider into the ChainConfigProvider instead of using SilexConfigServiceProvider's default.
1 parent 8461c89 commit 87fb45f

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

classes/OpenCFP/Application.php

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,18 @@
22

33
namespace OpenCFP;
44

5+
use Igorw\Silex\ChainConfigDriver;
6+
use Igorw\Silex\JsonConfigDriver;
7+
use Igorw\Silex\PhpConfigDriver;
8+
use Igorw\Silex\TomlConfigDriver;
59
use League\OAuth2\Server\Exception\OAuthException;
610
use OpenCFP\Provider\ApplicationServiceProvider;
711
use OpenCFP\Provider\Gateways\ApiGatewayProvider;
812
use OpenCFP\Provider\Gateways\OAuthGatewayProvider;
913
use OpenCFP\Provider\Gateways\WebGatewayProvider;
1014
use OpenCFP\Provider\ImageProcessorProvider;
1115
use OpenCFP\Provider\TwigServiceProvider;
16+
use OpenCFP\Provider\YamlConfigDriver;
1217
use Silex\Application as SilexApplication;
1318
use Igorw\Silex\ConfigServiceProvider;
1419
use OpenCFP\Provider\DatabaseServiceProvider;
@@ -120,7 +125,20 @@ private function camelCaseFrom($slug)
120125
*/
121126
protected function bindConfiguration()
122127
{
123-
$this->register(new ConfigServiceProvider($this->configPath(), [], null, 'config'));
128+
/**
129+
* Replace reference to `ChainConfigDriver` with `null` when PR below is merged.
130+
* Symfony's YAML package deprecated allowing a path to be passed to `parse` method.
131+
* This was causing our test-suite to fail. When this is merged, we can upgrade and
132+
* all will be well again.
133+
*
134+
* @see https://github.com/igorw/ConfigServiceProvider/pull/46
135+
*/
136+
$this->register(new ConfigServiceProvider($this->configPath(), [], new ChainConfigDriver([
137+
new PhpConfigDriver(),
138+
new YamlConfigDriver(), // This is ours; in OpenCFP/Provider/YamlConfigDriver.
139+
new JsonConfigDriver(),
140+
new TomlConfigDriver(),
141+
]), 'config'));
124142

125143
if ( ! $this->isProduction()) {
126144
$this['debug'] = true;
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
namespace OpenCFP\Provider;
4+
5+
use Igorw\Silex\YamlConfigDriver as IgorYamlConfigDriver;
6+
use Symfony\Component\Yaml\Yaml;
7+
8+
class YamlConfigDriver extends IgorYamlConfigDriver
9+
{
10+
public function load($filename)
11+
{
12+
if (!class_exists('Symfony\\Component\\Yaml\\Yaml')) {
13+
throw new \RuntimeException('Unable to read yaml as the Symfony Yaml Component is not installed.');
14+
}
15+
$config = Yaml::parse(file_get_contents($filename));
16+
return $config ?: array();
17+
}
18+
}

0 commit comments

Comments
 (0)