Improve names of factory methods in ORMTable. Now its clear that they create rows...
authorjeroendedauw <jeroendedauw@gmail.com>
Fri, 29 Jun 2012 18:56:44 +0000 (20:56 +0200)
committerjeroendedauw <jeroendedauw@gmail.com>
Fri, 29 Jun 2012 19:05:09 +0000 (21:05 +0200)
Change-Id: Ia83c7c81f4ddd6d3304273094553c31c67fe85c8

includes/db/IORMTable.php
includes/db/ORMResult.php
includes/db/ORMTable.php

index 8fa7220..684f4b4 100644 (file)
@@ -410,7 +410,7 @@ interface IORMTable {
         *
         * @return IORMRow
         */
-       public function newFromDBResult( stdClass $result );
+       public function newRowFromDBResult( stdClass $result );
 
        /**
         * Get a new instance of the class from an array.
@@ -422,7 +422,7 @@ interface IORMTable {
         *
         * @return IORMRow
         */
-       public function newFromArray( array $data, $loadDefaults = false );
+       public function newRow( array $data, $loadDefaults = false );
 
        /**
         * Return the names of the fields.
index 1342b02..3f2d803 100644 (file)
@@ -67,7 +67,7 @@ class ORMResult implements ORMIterator {
                if ( $row === false ) {
                        $this->current = false;
                } else {
-                       $this->current = $this->table->newFromDBResult( $row );
+                       $this->current = $this->table->newRowFromDBResult( $row );
                }
        }
 
index b6e2d52..9514562 100644 (file)
@@ -117,7 +117,7 @@ abstract class ORMTable implements IORMTable {
                $objects = array();
 
                foreach ( $result as $record ) {
-                       $objects[] = $this->newFromArray( $record );
+                       $objects[] = $this->newRow( $record );
                }
 
                return $objects;
@@ -618,8 +618,9 @@ abstract class ORMTable implements IORMTable {
        }
 
        /**
-        * Get a new instance of the class from a database result.
+        * @see ORMTable::newRowFromFromDBResult
         *
+        * @deprecated use newRowFromFromDBResult instead
         * @since 1.20
         *
         * @param stdClass $result
@@ -627,12 +628,26 @@ abstract class ORMTable implements IORMTable {
         * @return IORMRow
         */
        public function newFromDBResult( stdClass $result ) {
-               return $this->newFromArray( $this->getFieldsFromDBResult( $result ) );
+               return self::newRowFromFromDBResult( $result );
        }
 
        /**
-        * Get a new instance of the class from an array.
+        * Get a new instance of the class from a database result.
+        *
+        * @since 1.20
+        *
+        * @param stdClass $result
+        *
+        * @return IORMRow
+        */
+       public function newRowFromDBResult( stdClass $result ) {
+               return $this->newRow( $this->getFieldsFromDBResult( $result ) );
+       }
+
+       /**
+        * @see ORMTable::newRow
         *
+        * @deprecated use newRow instead
         * @since 1.20
         *
         * @param array $data
@@ -641,6 +656,20 @@ abstract class ORMTable implements IORMTable {
         * @return IORMRow
         */
        public function newFromArray( array $data, $loadDefaults = false ) {
+               return static::newRow( $data, $loadDefaults );
+       }
+
+       /**
+        * Get a new instance of the class from an array.
+        *
+        * @since 1.20
+        *
+        * @param array $data
+        * @param boolean $loadDefaults
+        *
+        * @return IORMRow
+        */
+       public function newRow( array $data, $loadDefaults = false ) {
                $class = $this->getRowClass();
                return new $class( $this, $data, $loadDefaults );
        }