Skip to content
This repository has been archived by the owner on Mar 4, 2019. It is now read-only.

Commit

Permalink
refactor: toEntity => convertToEntity, toEntities => convertToEntities
Browse files Browse the repository at this point in the history
  • Loading branch information
basuke committed Sep 14, 2011
1 parent f32bb29 commit cde97ea
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions models/entity_model.php
Expand Up @@ -11,16 +11,16 @@ class EntityModel extends EntityAppModel {
* @param $data Hash to be converted. If omitted, $this->data will be converted.
* @returns Entity object
*/
protected function toEntity($data) {
protected function convertToEntity($data) {
if (is_null($data) or empty($data[$this->name]['id'])) return null;

return $this->entity($data);
}

protected function toEntities($list_of_data) {
protected function convertToEntities($list_of_data) {
$result = array();
foreach ($list_of_data as $data) {
$result[] = $this->toEntity($data);
$result[] = $this->convertToEntity($data);
}
return $result;
}
Expand Down Expand Up @@ -60,7 +60,7 @@ public function afterFind($result, $primary) {
case 'all':
case 'first':
if ($this->entity and $primary) {
$result = $this->toEntities($result);
$result = $this->convertToEntities($result);
}
break;
}
Expand Down Expand Up @@ -107,7 +107,7 @@ public function call__($method, $params) {
$return = parent::call__($method, $params);

if ($to_entity and !is_null($return)) {
$return = ($all ? $this->toEntities($return) : $this->toEntity($return));
$return = ($all ? $this->convertToEntities($return) : $this->convertToEntity($return));
}

return $return;
Expand Down

0 comments on commit cde97ea

Please sign in to comment.