Permalink
Browse files

refactor: toEntity => convertToEntity, toEntities => convertToEntities

  • Loading branch information...
1 parent f32bb29 commit cde97ea70949a990dcc734dcb56672f661940278 @basuke basuke committed Sep 14, 2011
Showing with 5 additions and 5 deletions.
  1. +5 −5 models/entity_model.php
View
@@ -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;
}
@@ -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;
}
@@ -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;

0 comments on commit cde97ea

Please sign in to comment.