Пример #1
0
 /**
  * Factory for update
  *
  * @return Eve\Model\Profile\Update
  */
 public function update()
 {
     return Update::i();
 }
Пример #2
0
 /**
  * Processes the form
  *
  * @param array $data The item to process
  *
  * @return mixed
  */
 public function process(array $data = array())
 {
     //prevent uncatchable error
     if (count($this->errors($data))) {
         throw new Exception(self::FAIL_406);
     }
     //the uniqueness of a profile is from their id or email
     //if they change their email, they must provide a profile id
     //because there is no way to reference what to update
     //Simply put,
     //if profile id, we simply update it
     //if no profile id and email, $search for the email
     //    and if found, update it
     //    otherwise, insert it
     //if we do have a number, just update it
     if (is_numeric($data['profile_id'])) {
         return Update::i()->process($data);
     }
     //at this point we should have an email at least
     //search for it
     $search = eve()->database()->search('profile')->filterByProfileEmail($data['profile_email']);
     $row = $search->getRow();
     //if we found it
     if ($row) {
         //update it
         $data['profile_id'] = $row['profile_id'];
         return Update::i()->process($data);
     }
     //insert it
     return Create::i()->process($data);
 }