From 5dafc5f14f6de88562dc0b536137353804148dd9 Mon Sep 17 00:00:00 2001 From: jeroendedauw Date: Fri, 29 Jun 2012 20:56:44 +0200 Subject: [PATCH] Improve names of factory methods in ORMTable. Now its clear that they create rows and not tables Change-Id: Ia83c7c81f4ddd6d3304273094553c31c67fe85c8 --- includes/db/IORMTable.php | 4 ++-- includes/db/ORMResult.php | 2 +- includes/db/ORMTable.php | 37 +++++++++++++++++++++++++++++++++---- 3 files changed, 36 insertions(+), 7 deletions(-) diff --git a/includes/db/IORMTable.php b/includes/db/IORMTable.php index 8fa7220101..684f4b4638 100644 --- a/includes/db/IORMTable.php +++ b/includes/db/IORMTable.php @@ -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. diff --git a/includes/db/ORMResult.php b/includes/db/ORMResult.php index 1342b0243c..3f2d803632 100644 --- a/includes/db/ORMResult.php +++ b/includes/db/ORMResult.php @@ -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 ); } } diff --git a/includes/db/ORMTable.php b/includes/db/ORMTable.php index b6e2d52656..951456270a 100644 --- a/includes/db/ORMTable.php +++ b/includes/db/ORMTable.php @@ -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 ); } -- 2.20.1