Skip to content

Commit

Permalink
enables normalizeConfig() to handle irregular plural forms, e.g. fact…
Browse files Browse the repository at this point in the history
…ory -> factories
  • Loading branch information
schmittjoh authored and fabpot committed Jan 28, 2011
1 parent 81219bb commit 62d52d8
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/Symfony/Component/DependencyInjection/Extension/Extension.php
Expand Up @@ -84,14 +84,21 @@ public static function normalizeKeys(array $config)
*
* twig.extensions: ['twig.extension.foo', 'twig.extension.bar']
*
* @param array A config array
* @param key The key to normalize
* @param array $config A config array
* @param string $key The key to normalize
* @param string $plural The plural form of the key if it is irregular
*
* @return array
*/
public static function normalizeConfig($config, $key)
public static function normalizeConfig($config, $key, $plural = null)
{
if (null === $plural) {
$plural = $key.'s';
}

$values = array();
if (isset($config[$key.'s'])) {
$values = $config[$key.'s'];
if (isset($config[$plural])) {
$values = $config[$plural];
} elseif (isset($config[$key])) {
if (is_string($config[$key]) || !is_int(key($config[$key]))) {
// only one
Expand Down

0 comments on commit 62d52d8

Please sign in to comment.