当前位置: 首页>>代码示例>>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;未经允许,请勿转载。