Skip to content

Commit

Permalink
Merge branch 'oakey-b1-entity-to-array'
Browse files Browse the repository at this point in the history
  • Loading branch information
yunosh committed Sep 2, 2016
2 parents 23d7afd + e073223 commit 4fdd10e
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 6 deletions.
19 changes: 19 additions & 0 deletions framework/Rdo/doc/Horde/Rdo/UPGRADING
@@ -0,0 +1,19 @@
=====================
Upgrading Horde_Rdo
=====================

:Contact: dev@lists.horde.org

.. contents:: Contents
.. section-numbering::


This lists the API changes between releases of the package.


Upgrading to 2.1.0
==================

- Horde_Rdo_Base

- The toArray() method has been added.
44 changes: 44 additions & 0 deletions framework/Rdo/lib/Horde/Rdo/Base.php
Expand Up @@ -446,4 +446,48 @@ protected function _fillPlaceholders($query)
return $query;
}

/**
* Converts the entity to an Array.
*
* This method can be used when handing it over to Horde_Variables so that
* the database is not unnecessarily queried because of
* lazyFields/lazyRelationships.
*
* @since Horde_Rdo 2.1.0
*
* @param bool $lazy Whether lazy elements should be added.
* @param bool $relationships Whether relationships should be added.
*
* @return array All selected fields and relationships.
*/
public function toArray($lazy = false, $relationships = false)
{
$array = array();

$m = $this->getMapper();

foreach ($m->fields as $field) {
$array[$field] = $this->$field;
}

if ($lazy) {
foreach ($m->lazyFields as $field) {
$array[$field] = $this->$field;
}
}

if ($relationships) {
foreach (array_keys($m->relationships) as $rel) {
$array[$rel] = $this->$rel;
}
}

if ($lazy && $relationships) {
foreach (array_keys($m->lazyRelationships) as $rel) {
$array[$rel] = $this->$rel;
}
}

return $array;
}
}
16 changes: 10 additions & 6 deletions framework/Rdo/package.xml
Expand Up @@ -11,17 +11,18 @@
<email>chuck@horde.org</email>
<active>yes</active>
</lead>
<date>2016-02-02</date>
<date>2016-09-02</date>
<version>
<release>2.0.6</release>
<api>1.2.0</api>
<release>2.1.0</release>
<api>1.3.0</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<license uri="http://www.horde.org/licenses/lgpl21">LGPL-2.1</license>
<notes>
* [jan] Add Horde_Rdo_Base#toArray() (Neal Thomas Oakey &lt;oakey@b1-systems.de&gt;).
* [jan] Make the JOIN type settable by mapper relationships (Neal Thomas Oakey &lt;oakey@b1-systems.de&gt;).
</notes>
<contents>
Expand All @@ -45,6 +46,7 @@
</dir> <!-- /doc/Horde/Rdo/examples -->
<file name="COPYING" role="doc" />
<file name="TODO" role="doc" />
<file name="UPGRADING" role="doc" />
</dir> <!-- /doc/Horde/Rdo -->
</dir> <!-- /doc/Horde -->
</dir> <!-- /doc -->
Expand Down Expand Up @@ -144,6 +146,7 @@
<filelist>
<install as="COPYING" name="doc/Horde/Rdo/COPYING" />
<install as="TODO" name="doc/Horde/Rdo/TODO" />
<install as="UPGRADING" name="doc/Horde/Rdo/UPGRADING" />
<install as="examples/clotho.data.php" name="doc/Horde/Rdo/examples/clotho.data.php" />
<install as="examples/clotho.mysql.sql" name="doc/Horde/Rdo/examples/clotho.mysql.sql" />
<install as="examples/Clotho.php" name="doc/Horde/Rdo/examples/Clotho.php" />
Expand Down Expand Up @@ -404,14 +407,15 @@ Major improvements including inflection, eager or lazy loading of relationships
</release>
<release>
<version>
<release>2.0.6</release>
<api>1.2.0</api></version>
<release>2.1.0</release>
<api>1.3.0</api></version>
<stability>
<release>stable</release>
<api>stable</api></stability>
<date>2016-02-02</date>
<date>2016-09-02</date>
<license uri="http://www.horde.org/licenses/lgpl21">LGPL-2.1</license>
<notes>
* [jan] Add Horde_Rdo_Base#toArray() (Neal Thomas Oakey &lt;oakey@b1-systems.de&gt;).
* [jan] Make the JOIN type settable by mapper relationships (Neal Thomas Oakey &lt;oakey@b1-systems.de&gt;).
</notes>
</release>
Expand Down

0 comments on commit 4fdd10e

Please sign in to comment.