本文整理汇总了PHP中UserManager::getUserByIdentifier方法的典型用法代码示例。如果您正苦于以下问题:PHP UserManager::getUserByIdentifier方法的具体用法?PHP UserManager::getUserByIdentifier怎么用?PHP UserManager::getUserByIdentifier使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserManager
的用法示例。
在下文中一共展示了UserManager::getUserByIdentifier方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getUserByName
/**
* Returns the user that match the given string
*
* @param String $user_name
* @return PFUser
* @throws Exception
*/
public function getUserByName($user_name)
{
$user = $this->user_manager->getUserByIdentifier($user_name);
if ($user && $user->isAlive()) {
return $user;
}
throw new Exception('Invalid user');
}
示例2: getUser
/**
* @param SimpleXMLElement $xml_element
* @return PFUser
*/
public function getUser(SimpleXMLElement $xml_element)
{
$submitter = $this->user_manager->getUserByIdentifier($this->getUserFormat($xml_element));
if (!$submitter) {
$submitter = $this->user_manager->getUserAnonymous();
$submitter->setEmail((string) $xml_element);
}
return $submitter;
}
示例3: getFieldDataFromRESTObject
public function getFieldDataFromRESTObject(array $rest_data, Tracker_FormElement_Field_List $field)
{
if (isset($rest_data['id']) && is_numeric($rest_data['id'])) {
$id = (int) $rest_data['id'];
$user = $this->getValue($id);
if (!$user) {
throw new Tracker_FormElement_InvalidFieldValueException('Cannot Bind to user with ID ' . $id . ' for field ID ' . $field->getId());
}
return Tracker_FormElement_Field_OpenList::BIND_PREFIX . $id;
}
if (isset($rest_data['username'])) {
$identifier = (string) $rest_data['username'];
$user = $this->userManager->getUserByIdentifier($identifier);
if (!$user) {
throw new Tracker_FormElement_InvalidFieldValueException('Cannot Bind to user "' . $identifier . '" for field ID ' . $field->getId());
}
return Tracker_FormElement_Field_OpenList::BIND_PREFIX . $user->getId();
}
if (!isset($rest_data['email'])) {
throw new Tracker_FormElement_InvalidFieldValueException('OpenList user fields values should be passed as an object with at least one of the properties "id", "username" or "email"');
}
$identifier = (string) $rest_data['email'];
$user = $this->userManager->getUserByIdentifier("email:{$identifier}");
if (!$user) {
return Tracker_FormElement_Field_OpenList::NEW_VALUE_PREFIX . $identifier;
}
return Tracker_FormElement_Field_OpenList::BIND_PREFIX . $user->getId();
}
示例4: getListOfUgroupMember
/**
* @param SimpleXMLElement $ugroup
*
* @return PFUser[]
*/
private function getListOfUgroupMember(SimpleXMLElement $ugroup)
{
$ugroup_members = array();
foreach ($ugroup->members->member as $xml_member) {
$identifier = $this->xml_helper->getUserFormat($xml_member);
$user = $this->user_manager->getUserByIdentifier($identifier);
if (!$user) {
$this->logger->debug("User ({$identifier}) does not exist -> skipped");
continue;
}
$ugroup_members[] = $user;
}
return $ugroup_members;
}
示例5: isValid
public function isValid($value)
{
if ($value) {
$values = explode(',', $value);
foreach ($values as $v) {
if (stripos($v, '!') !== false) {
//we check the string is an email
$rule = new Rule_Email();
if (!$rule->isValid($v)) {
//we check the string correspond to a username
if (!$this->userManager->getUserByIdentifier(substr($v, 1))) {
return false;
}
}
}
}
}
return true;
}