IniRepository: Introduce method createConfig

refs #13034
This commit is contained in:
Johannes Meyer 2016-11-04 10:16:45 +01:00
parent a0db5bea87
commit c44e164de9
1 changed files with 28 additions and 0 deletions

View File

@ -377,6 +377,34 @@ abstract class IniRepository extends Repository implements Extensible, Updatable
}
}
/**
* Create and return a Config for the given meta and table
*
* @param array $meta
* @param string $table
*
* @return Config
*
* @throws ProgrammingError In case the given meta is invalid
*/
protected function createConfig(array $meta, $table)
{
if (! isset($meta['name'])) {
throw new ProgrammingError('Config file name missing for table "%s"', $table);
} elseif (! isset($meta['keyColumn'])) {
throw new ProgrammingError('Config key column name missing for table "%s"', $table);
}
if (isset($meta['module'])) {
$config = Config::module($meta['module'], $meta['name']);
} else {
$config = Config::app($meta['name']);
}
$config->getConfigObject()->setKeyColumn($meta['keyColumn']);
return $config;
}
/**
* Extract and return the section name off of the given $config
*