mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-27 15:54:03 +02:00
IniRepository: Directly pass the key column to method extractSectionName
refs #13034
This commit is contained in:
parent
ac3e182f0d
commit
3c5fe76cc0
@ -257,7 +257,7 @@ abstract class IniRepository extends Repository implements Extensible, Updatable
|
|||||||
{
|
{
|
||||||
$newData = $this->requireStatementColumns($target, $data);
|
$newData = $this->requireStatementColumns($target, $data);
|
||||||
$config = $this->onInsert($target, new ConfigObject($newData));
|
$config = $this->onInsert($target, new ConfigObject($newData));
|
||||||
$section = $this->extractSectionName($config, $target);
|
$section = $this->extractSectionName($config, $this->getDataSource($target)->getConfigObject()->getKeyColumn());
|
||||||
|
|
||||||
if ($this->getDataSource($target)->hasSection($section)) {
|
if ($this->getDataSource($target)->hasSection($section)) {
|
||||||
throw new StatementException(t('Cannot insert. Section "%s" does already exist'), $section);
|
throw new StatementException(t('Cannot insert. Section "%s" does already exist'), $section);
|
||||||
@ -375,15 +375,14 @@ abstract class IniRepository extends Repository implements Extensible, Updatable
|
|||||||
* Extract and return the section name off of the given $config
|
* Extract and return the section name off of the given $config
|
||||||
*
|
*
|
||||||
* @param array|ConfigObject $config
|
* @param array|ConfigObject $config
|
||||||
* @param string $target The table whose datasource to get the key column from
|
* @param string $keyColumn
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*
|
*
|
||||||
* @throws ProgrammingError In case no valid section name is available
|
* @throws ProgrammingError In case no valid section name is available
|
||||||
*/
|
*/
|
||||||
protected function extractSectionName( & $config, $target)
|
protected function extractSectionName( & $config, $keyColumn)
|
||||||
{
|
{
|
||||||
$keyColumn = $this->getDataSource($target)->getConfigObject()->getKeyColumn();
|
|
||||||
if (! is_array($config) && !$config instanceof ConfigObject) {
|
if (! is_array($config) && !$config instanceof ConfigObject) {
|
||||||
throw new ProgrammingError('$config is neither an array nor a ConfigObject');
|
throw new ProgrammingError('$config is neither an array nor a ConfigObject');
|
||||||
} elseif (! isset($config[$keyColumn])) {
|
} elseif (! isset($config[$keyColumn])) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user