Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Commit

Permalink
Merge branch 'hotfix/37'
Browse files Browse the repository at this point in the history
Close #38
Fixes #37
  • Loading branch information
weierophinney committed Apr 11, 2017
2 parents 5b76cc3 + ad6a7c3 commit 700a22e
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 2 deletions.
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,28 @@

All notable changes to this project will be documented in this file, in reverse chronological order by release.

## 0.7.1 - 2017-04-11

### Added

- Nothing.

### Deprecated

- Nothing.

### Removed

- Nothing.

### Fixed

- [#38](https://github.com/zendframework/zend-component-installer/pull/38) fixes
an issue with detection of config providers in `ConfigAggregator`-based
configuration files. Previously, entries that were globally qualified
(prefixed with `\\`) were not properly detected, leading to the installer
re-asking to inject.

## 0.7.0 - 2017-02-22

### Added
Expand Down
7 changes: 5 additions & 2 deletions src/Injector/ConfigAggregatorInjector.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,14 @@ class ConfigAggregatorInjector extends AbstractInjector
*/
public function __construct($projectRoot = '')
{
$ns = preg_quote('\\');
$this->isRegisteredPattern = '/new (?:'
. preg_quote('\\')
. $ns
. '?'
. preg_quote('Zend\ConfigAggregator\\')
. ')?ConfigAggregator\(\s*(?:array\(|\[).*\s+%s::class/s';
. ')?ConfigAggregator\(\s*(?:array\(|\[).*\s+'
. $ns
. '?%s::class/s';

$this->injectionPatterns[self::TYPE_CONFIG_PROVIDER]['pattern'] = sprintf(
"/(new (?:%s?%s)?ConfigAggregator\(\s*(?:array\(|\[)\s*)(?:\r|\n|\r\n)(\s*)/",
Expand Down
11 changes: 11 additions & 0 deletions test/Injector/ConfigAggregatorInjectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

namespace ZendTest\ComponentInstaller\Injector;

use org\bovigo\vfs\vfsStream;
use Zend\ComponentInstaller\Injector\ConfigAggregatorInjector;

class ConfigAggregatorInjectorTest extends AbstractInjectorTestCase
Expand Down Expand Up @@ -151,4 +152,14 @@ public function packagePopulatedInConfiguration()
];
// @codingStandardsIgnoreEnd
}

public function testProperlyDetectsExistingConfigProviderInConfigWithMixedRelativeAndGloballyQualifiedNames()
{
$contents = file_get_contents(__DIR__ . '/TestAsset/expressive-application-from-skeleton.config.php');
vfsStream::newFile('config/config.php')
->at($this->configDir)
->setContent($contents);

$this->assertTrue($this->injector->isRegistered('Zend\Validator\ConfigProvider'));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

use Zend\ConfigAggregator\ArrayProvider;
use Zend\ConfigAggregator\ConfigAggregator;
use Zend\ConfigAggregator\PhpFileProvider;

// To enable or disable caching, set the `ConfigAggregator::ENABLE_CACHE` boolean in
// `config/autoload/local.php`.
$cacheConfig = [
'config_cache_path' => 'data/config-cache.php',
];

$aggregator = new ConfigAggregator([
\Zend\Validator\ConfigProvider::class,
\Zend\InputFilter\ConfigProvider::class,
\Zend\Filter\ConfigProvider::class,
\Zend\Mail\ConfigProvider::class,
\Contact\ConfigProvider::class,
// Include cache configuration
new ArrayProvider($cacheConfig),

// Default App module config
App\ConfigProvider::class,

// Load application config in a pre-defined order in such a way that local settings
// overwrite global settings. (Loaded as first to last):
// - `global.php`
// - `*.global.php`
// - `local.php`
// - `*.local.php`
new PhpFileProvider('config/autoload/{{,*.}global,{,*.}local}.php'),

// Load development config if it exists
new PhpFileProvider('config/development.config.php'),
], $cacheConfig['config_cache_path']);

return $aggregator->getMergedConfig();

0 comments on commit 700a22e

Please sign in to comment.