当前位置: 首页>>代码示例>>PHP>>正文


PHP User::findUser方法代码示例

本文整理汇总了PHP中thebuggenie\core\entities\User::findUser方法的典型用法代码示例。如果您正苦于以下问题:PHP User::findUser方法的具体用法?PHP User::findUser怎么用?PHP User::findUser使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在thebuggenie\core\entities\User的用法示例。


在下文中一共展示了User::findUser方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getOrCreateUserFromEmailString

 public function getOrCreateUserFromEmailString($email_string)
 {
     $email = $this->getEmailAdressFromSenderString($email_string);
     if (!($user = User::findUser($email))) {
         $name = $email;
         if (($q_pos = strpos($email_string, "<")) !== false) {
             $name = trim(substr($email_string, 0, $q_pos - 1));
         }
         $user = new User();
         try {
             $user->setBuddyname($name);
             $user->setEmail($email);
             $user->setUsername($email);
             $user->setValidated();
             $user->setActivated();
             $user->setEnabled();
             $user->save();
         } catch (\Exception $e) {
             return null;
         }
     }
     return $user;
 }
开发者ID:RTechSoft,项目名称:thebuggenie,代码行数:23,代码来源:Mailing.php

示例2: runUpdateIssueDetails


//.........这里部分代码省略.........
                             case 'description':
                             case 'reproduction_steps':
                                 $method = "set" . ucfirst($field_key);
                                 $issue->{$method}($field_value);
                                 break;
                             case 'status':
                             case 'resolution':
                             case 'reproducability':
                             case 'priority':
                             case 'severity':
                             case 'category':
                                 $classname = "\\thebuggenie\\core\\entities\\" . ucfirst($field_key);
                                 $method = "set" . ucfirst($field_key);
                                 $choices = $classname::getAll();
                                 $found = false;
                                 foreach ($choices as $choice_key => $choice) {
                                     if (str_replace(' ', '', mb_strtolower($choice->getName())) == str_replace(' ', '', mb_strtolower($field_value))) {
                                         $issue->{$method}($choice);
                                         $found = true;
                                     }
                                 }
                                 if (!$found) {
                                     throw new \Exception('Could not find this value');
                                 }
                                 break;
                             case 'percent_complete':
                                 $issue->setPercentCompleted($field_value);
                                 break;
                             case 'owner':
                             case 'assignee':
                                 $set_method = "set" . ucfirst($field_key);
                                 $unset_method = "un{$set_method}";
                                 switch (mb_strtolower($field_value)) {
                                     case 'me':
                                         $issue->{$set_method}(framework\Context::getUser());
                                         break;
                                     case 'none':
                                         $issue->{$unset_method}();
                                         break;
                                     default:
                                         try {
                                             $user = entities\User::findUser(mb_strtolower($field_value));
                                             if ($user instanceof entities\User) {
                                                 $issue->{$set_method}($user);
                                             }
                                         } catch (\Exception $e) {
                                             throw new \Exception('No such user found');
                                         }
                                         break;
                                 }
                                 break;
                             case 'estimated_time':
                             case 'spent_time':
                                 $set_method = "set" . ucfirst(str_replace('_', '', $field_key));
                                 $issue->{$set_method}($field_value);
                                 break;
                             case 'milestone':
                                 $found = false;
                                 foreach ($this->selected_project->getMilestones() as $milestone) {
                                     if (str_replace(' ', '', mb_strtolower($milestone->getName())) == str_replace(' ', '', mb_strtolower($field_value))) {
                                         $issue->setMilestone($milestone->getID());
                                         $found = true;
                                     }
                                 }
                                 if (!$found) {
                                     throw new \Exception('Could not find this milestone');
                                 }
                                 break;
                             default:
                                 throw new \Exception($i18n->__('Invalid field'));
                         }
                     }
                     $return_values[$field_key] = array('success' => true);
                 } catch (\Exception $e) {
                     $return_values[$field_key] = array('success' => false, 'error' => $e->getMessage());
                 }
             }
         }
         if (!$workflow_transition instanceof entities\WorkflowTransition) {
             $issue->getWorkflow()->moveIssueToMatchingWorkflowStep($issue);
         }
         if (!array_key_exists('transition_ok', $return_values) || $return_values['transition_ok']) {
             $comment = new entities\Comment();
             $comment->setContent($request->getParameter('message', null, false));
             $comment->setPostedBy(framework\Context::getUser()->getID());
             $comment->setTargetID($issue->getID());
             $comment->setTargetType(entities\Comment::TYPE_ISSUE);
             $comment->setModuleName('core');
             $comment->setIsPublic(true);
             $comment->setSystemComment(false);
             $comment->save();
             $issue->setSaveComment($comment);
             $issue->save();
         }
         $this->return_values = $return_values;
     } catch (\Exception $e) {
         //$this->getResponse()->setHttpStatus(400);
         return $this->renderJSON(array('failed' => true, 'error' => $e->getMessage()));
     }
 }
开发者ID:JonathanRH,项目名称:thebuggenie,代码行数:101,代码来源:Main.php


注:本文中的thebuggenie\core\entities\User::findUser方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。