本文整理汇总了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;
}