コード例 #1
0
ファイル: DataMapper.php プロジェクト: sonvq/2015_freelance6
 public function getModelFromArray(array $data)
 {
     $fields = array('author_id' => null, 'vacancy_id' => null, 'title' => null, 'description' => null, 'phone' => null, 'mobile' => null, 'email' => null, 'term' => null, 'region' => null, 'category_id' => null, 'hours' => null, 'seeker_name' => null, 'seeker_fname' => null, 'date_expired' => null, 'date_published' => null);
     foreach ($data as $key => $value) {
         if (array_key_exists($key, $fields)) {
             $fields[$key] = $value;
         }
     }
     $vacancy = new SxCms_Job();
     $vacancy->setId($fields['vacancy_id'])->setJobtitle($fields['title'])->setDescription($fields['description'])->setPhone($fields['phone'])->setMobile($fields['mobile'])->setEmail($fields['email'])->setTerm($fields['term'])->setSeekerFirstName($fields['seeker_name'])->setSeekerName($fields['seeker_fname']);
     $address = new SxCms_Address();
     $address->setRegion($fields['region']);
     $category = new SxCms_Job_Category();
     $category->setId($fields['category_id']);
     $vacancy->setCategory($category);
     $vacancy->setAddress($address)->setHours($fields['hours'])->setExpireDate($fields['date_expired'])->setPublicationDate($fields['date_published']);
     return $vacancy;
 }