From: addshore Date: Thu, 14 Jun 2018 07:36:42 +0000 (+0100) Subject: Move getFieldsToStore to own method in NameTableStore X-Git-Tag: 1.34.0-rc.0~5044^2 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/banques/?a=commitdiff_plain;h=f84d47160c77906419527967b966ea7c3cc56a1b;p=lhc%2Fweb%2Fwiklou.git Move getFieldsToStore to own method in NameTableStore In the future this opens up an easy posibility of subclassing if this is made protected. Change-Id: I640c9f12f52dbb3328523402d9223ee8c967adda --- diff --git a/includes/Storage/NameTableStore.php b/includes/Storage/NameTableStore.php index 505ab4c321..1982d028f0 100644 --- a/includes/Storage/NameTableStore.php +++ b/includes/Storage/NameTableStore.php @@ -352,14 +352,9 @@ class NameTableStore { $dbw = $this->getDBConnection( DB_MASTER ); - $insertFields = [ $this->nameField => $name ]; - if ( $this->insertCallback !== null ) { - $insertFields = call_user_func( $this->insertCallback, $insertFields ); - } - $dbw->insert( $this->table, - $insertFields, + $this->getFieldsToStore( $name ), __METHOD__, [ 'IGNORE' ] ); @@ -374,4 +369,16 @@ class NameTableStore { return $dbw->insertId(); } + /** + * @param string $name + * @return array + */ + private function getFieldsToStore( $name ) { + $fields = [ $this->nameField => $name ]; + if ( $this->insertCallback !== null ) { + $fields = call_user_func( $this->insertCallback, $fields ); + } + return $fields; + } + }