コード例 #1
0
ファイル: Rates.php プロジェクト: kalburgimanjunath/system
 /**
  * method to convert plans ref into their name
  * triggered before present the rate entity for edit
  * 
  * @param Mongodloid collection $collection
  * @param array $entity
  * 
  * @return type
  * @todo move to model
  */
 public function getItem($id)
 {
     $entity = parent::getItem($id);
     if (isset($entity['rates'])) {
         $raw_data = $entity->getRawData();
         foreach ($raw_data['rates'] as &$rate) {
             if (isset($rate['plans'])) {
                 foreach ($rate['plans'] as &$plan) {
                     $data = $this->collection->getRef($plan);
                     if ($data instanceof Mongodloid_Entity) {
                         $plan = $data->get('name');
                     }
                 }
             }
         }
         $entity->setRawData($raw_data);
     }
     return $entity;
 }