本文整理匯總了PHP中entity::addExtension方法的典型用法代碼示例。如果您正苦於以下問題:PHP entity::addExtension方法的具體用法?PHP entity::addExtension怎麽用?PHP entity::addExtension使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類entity
的用法示例。
在下文中一共展示了entity::addExtension方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: mergePeople
private function mergePeople($proxyPerson, $formPerson)
{
$formPerson->name_first;
$formPerson->name_last;
$person = new entity();
$person->addExtension('Person');
$person->name_first = $formPerson->name_first;
$person->name_middle = $formPerson->name_middle;
$person->name_last = $formPerson->name_last;
$person->name_nick = $formPerson->name_nick;
$person->name_prefix = $formPerson->name_prefix;
$person->name_suffix = $formPerson->name_suffix;
$compatible = false;
if (!$proxyPerson->name_first or $proxyPerson->name_first == '') {
return $person;
}
//check first name compatibility before doing anything
if (stripos($proxyPerson->name_first, $formPerson->name_first) === 0 || stripos($formPerson->name_first, $proxyPerson->name_first) === 0) {
if ($formPerson->name_middle == null || $formPerson->name_middle == '') {
$compatible = true;
$person->name_middle = $proxyPerson->name_middle;
if (strlen($proxyPerson->name_first) > strlen($formPerson->name_first)) {
$person->name_first = $proxyPerson->name_first;
}
} else {
if (!$proxyPerson->name_middle || $proxyPerson->name_middle == '') {
$compatible = true;
if (strlen($proxyPerson->name_first) > strlen($formPerson->name_first)) {
$person->name_first = $proxyPerson->name_first;
}
} else {
if (stripos($proxyPerson->name_middle, $formPerson->name_middle) === 0 || stripos($formPerson->name_middle, $proxyPerson->name_middle) === 0) {
$compatible = true;
if (strlen($proxyPerson->name_middle) > strlen($formPerson->name_middle)) {
$person->name_middle = $proxyPerson->name_middle;
}
if (strlen($proxyPerson->name_first) > strlen($formPerson->name_first)) {
$person->name_first = $proxyPerson->name_first;
}
}
}
}
}
//if names have proven compatible, then check generational suffixes (Jr, Sr etc)
if ($compatible == true) {
$form_suffixes = explode(' ', $formPerson->name_suffix);
$form_generationals = array_intersect($form_suffixes, LsLanguage::$generationalSuffixes);
$proxy_suffixes = explode(' ', $proxyPerson->name_suffix);
$common_generationals = array_intersect($form_generationals, $proxy_suffixes);
//if there are no generationals in the form 4 name, go ahead and grab prefixes, suffixes, etc from proxy name
if (count($form_generationals) == 0 || ($form_generationals = $common_generationals)) {
if (strlen($proxyPerson->name_nick) > strlen($formPerson->name_nick)) {
$person->name_nick = $proxyPerson->name_nick;
}
if (strlen($proxyPerson->name_prefix) > strlen($formPerson->name_prefix)) {
$person->name_prefix = $proxyPerson->name_prefix;
}
if (strlen($proxyPerson->name_suffix) > strlen($formPerson->name_suffix)) {
$person->name_suffix = $proxyPerson->name_suffix;
}
}
}
return $person;
}