本文整理汇总了PHP中Phone::setDeviceId方法的典型用法代码示例。如果您正苦于以下问题:PHP Phone::setDeviceId方法的具体用法?PHP Phone::setDeviceId怎么用?PHP Phone::setDeviceId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Phone
的用法示例。
在下文中一共展示了Phone::setDeviceId方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: findPerson
/**
* Try to find this person in the database.
* If we cannot find them, create a new person record.
*
* @return Person
*/
public static function findPerson($post)
{
$search = array();
// Translates Open311 parameters into PersonList search parameters
// open311 => personList
$fields = array('first_name' => 'firstname', 'last_name' => 'lastname', 'email' => 'email', 'phone' => 'phoneNumber', 'device_id' => 'phoneDeviceId');
foreach ($fields as $open311Field => $crmField) {
if (!empty($post[$open311Field])) {
$search[$crmField] = $post[$open311Field];
}
}
// If the user provided any personal info, do a person search
if (count($search)) {
$table = new PersonTable();
$list = $table->find($search);
// When we find one and only one record, use the record we found
if (count($list) == 1) {
$person = $list->current();
} else {
$p = array();
foreach ($fields as $key => $field) {
if (!empty($post[$key])) {
$p[$field] = $post[$key];
}
}
if (count($p)) {
$person = new Person();
try {
$person->handleUpdate($p);
$person->save();
if (!empty($post['email'])) {
$email = new Email();
$email->setPerson($person);
$email->setEmail($post['email']);
$email->save();
}
if (!empty($post['phone']) || !empty($post['device_id'])) {
$phone = new Phone();
$phone->setPerson($person);
if (!empty($post['phone'])) {
$phone->setNumber($post['phone']);
}
if (!empty($post['device_id'])) {
$phone->setDeviceId($post['device_id']);
}
$phone->save();
}
} catch (\Exception $e) {
unset($person);
}
}
}
}
return isset($person) ? $person : null;
}