當前位置: 首頁>>代碼示例>>PHP>>正文


PHP entity::addExtension方法代碼示例

本文整理匯總了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;
 }
開發者ID:silky,項目名稱:littlesis,代碼行數:64,代碼來源:PublicCompanyRosterScraper.class.php


注:本文中的entity::addExtension方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。