/**
  * Insert contact
  *
  * @param Contact $contact
  */
 protected function contactUpdate(Contact $contact)
 {
     $db = $this->getDatabaseDriver();
     $parts = array();
     foreach ($contact->getFields() as $field => $fieldValue) {
         $parts[] = "`" . $field . "` = " . $db->quote($fieldValue);
     }
     $query = "\n            UPDATE `contact`\n            SET\n                `updated_at` = NOW(),\n                " . implode($parts, ', ') . "\n            WHERE `id` = " . $db->quote($contact->getId()) . "\n            LIMIT 1\n        ";
     $db->query($query);
 }
示例#2
0
 /**
  * Sets supervisor.
  *
  * @param Contact $supervisor
  * @return Contact
  */
 public function setSupervisor($supervisor)
 {
     $this->supervisor = $supervisor;
     $this->setField('supervisor_contact_id', isset($supervisor) ? $supervisor->getId() : null);
     return $this;
 }
 /**
  * Transform contact to transient data
  *
  * @param Contact $contact
  * @returns array
  */
 public static function toTransient(Contact $contact)
 {
     $supervisor = $contact->getSupervisor();
     return ['id' => $contact->getId(), 'title' => $contact->getTitle(), 'name' => $contact->getName(), 'email' => $contact->getEmail(), 'supervisor' => $supervisor ? self::toTransient($supervisor) : null, 'supervised_contacts' => self::listToTransient($contact->getSupervisedContacts())];
 }