From: jeroendedauw Date: Fri, 29 Jun 2012 18:56:44 +0000 (+0200) Subject: Improve names of factory methods in ORMTable. Now its clear that they create rows... X-Git-Tag: 1.31.0-rc.0~22097^2^2~79 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_aide%28?a=commitdiff_plain;h=52ff5673139d01c409a577e4b03210c4d6e6ad54;p=lhc%2Fweb%2Fwiklou.git Improve names of factory methods in ORMTable. Now its clear that they create rows and not tables Change-Id: Ia83c7c81f4ddd6d3304273094553c31c67fe85c8 --- 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 ); }