[icinga-checkins] icinga.org: icingaweb2/feature/announce-banner-11198: IniRepository: Directly pass the key column to method extractSectionName

git at icinga.org git at icinga.org
Fri Nov 4 10:50:04 CET 2016


Module: icingaweb2
Branch: feature/announce-banner-11198
Commit: 3c5fe76cc0addeaa098ffeb4b0239fb46b838847
URL:    https://git.icinga.org/?p=icingaweb2.git;a=commit;h=3c5fe76cc0addeaa098ffeb4b0239fb46b838847

Author: Johannes Meyer <johannes.meyer at netways.de>
Date:   Fri Nov  4 10:04:42 2016 +0100

IniRepository: Directly pass the key column to method extractSectionName

refs #13034

---

 library/Icinga/Repository/IniRepository.php |    7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/library/Icinga/Repository/IniRepository.php b/library/Icinga/Repository/IniRepository.php
index da1a57c..725c6df 100644
--- a/library/Icinga/Repository/IniRepository.php
+++ b/library/Icinga/Repository/IniRepository.php
@@ -257,7 +257,7 @@ abstract class IniRepository extends Repository implements Extensible, Updatable
     {
         $newData = $this->requireStatementColumns($target, $data);
         $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)) {
             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
      *
      * @param   array|ConfigObject  $config
-     * @param   string              $target The table whose datasource to get the key column from
+     * @param   string              $keyColumn
      *
      * @return  string
      *
      * @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) {
             throw new ProgrammingError('$config is neither an array nor a ConfigObject');
         } elseif (! isset($config[$keyColumn])) {



More information about the icinga-checkins mailing list