Move getFieldsToStore to own method in NameTableStore
authoraddshore <addshorewiki@gmail.com>
Thu, 14 Jun 2018 07:36:42 +0000 (08:36 +0100)
committerAddshore <addshorewiki@gmail.com>
Fri, 15 Jun 2018 07:28:37 +0000 (07:28 +0000)
In the future this opens up an easy posibility of subclassing
if this is made protected.

Change-Id: I640c9f12f52dbb3328523402d9223ee8c967adda

includes/Storage/NameTableStore.php

index 505ab4c..1982d02 100644 (file)
@@ -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;
+       }
+
 }