本文整理汇总了PHP中PhabricatorUser::loadHandles方法的典型用法代码示例。如果您正苦于以下问题:PHP PhabricatorUser::loadHandles方法的具体用法?PHP PhabricatorUser::loadHandles怎么用?PHP PhabricatorUser::loadHandles使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PhabricatorUser
的用法示例。
在下文中一共展示了PhabricatorUser::loadHandles方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getEditorValue
public function getEditorValue(PhabricatorUser $viewer, $target)
{
try {
$type = $this->getHeraldActionStandardType();
} catch (PhutilMethodNotImplementedException $ex) {
return $target;
}
switch ($type) {
case self::STANDARD_PHID_LIST:
$handles = $viewer->loadHandles($target);
$handles = iterator_to_array($handles);
return mpull($handles, 'getName', 'getPHID');
}
return $target;
}
示例2: getEditorValue
public function getEditorValue(PhabricatorUser $viewer, $value)
{
// TODO: This should be better structured and pushed down into individual
// fields. As it is used to manually build tokenizer tokens, it can
// probably be removed entirely.
if (is_array($value)) {
$handles = $viewer->loadHandles($value);
$value_map = array();
foreach ($value as $k => $phid) {
$value_map[$phid] = $handles[$phid]->getName();
}
$value = $value_map;
}
return $value;
}
示例3: renderPostList
protected function renderPostList(array $posts, PhabricatorUser $viewer, $nodata)
{
assert_instances_of($posts, 'PhamePost');
$handle_phids = array();
foreach ($posts as $post) {
$handle_phids[] = $post->getBloggerPHID();
if ($post->getBlog()) {
$handle_phids[] = $post->getBlog()->getPHID();
}
}
$handles = $viewer->loadHandles($handle_phids);
$stories = array();
foreach ($posts as $post) {
$blogger = $handles[$post->getBloggerPHID()]->renderLink();
$blogger_uri = $handles[$post->getBloggerPHID()]->getURI();
$blogger_image = $handles[$post->getBloggerPHID()]->getImageURI();
$blog = null;
if ($post->getBlog()) {
$blog = $handles[$post->getBlog()->getPHID()]->renderLink();
}
$phame_post = '';
if ($post->getBody()) {
$phame_post = PhabricatorMarkupEngine::summarize($post->getBody());
}
$blog_view = $post->getViewURI();
$phame_title = phutil_tag('a', array('href' => $blog_view), $post->getTitle());
$blogger = phutil_tag('strong', array(), $blogger);
if ($post->isDraft()) {
$title = pht('%s drafted a blog post on %s.', $blogger, $blog);
$title = phutil_tag('em', array(), $title);
} else {
$title = pht('%s wrote a blog post on %s.', $blogger, $blog);
}
$item = id(new PHUIObjectItemView())->setObject($post)->setHeader($post->getTitle())->setHref($this->getApplicationURI('post/view/' . $post->getID() . '/'));
$story = id(new PHUIFeedStoryView())->setTitle($title)->setImage($blogger_image)->setImageHref($blogger_uri)->setAppIcon('fa-star')->setUser($viewer)->setPontification($phame_post, $phame_title);
if (PhabricatorPolicyFilter::hasCapability($viewer, $post, PhabricatorPolicyCapability::CAN_EDIT)) {
$story->addAction(id(new PHUIIconView())->setHref($this->getApplicationURI('post/edit/' . $post->getID() . '/'))->setIconFont('fa-pencil'));
}
if ($post->getDatePublished()) {
$story->setEpoch($post->getDatePublished());
}
$stories[] = $story;
}
if (empty($stories)) {
return id(new PHUIBoxView())->appendChild($nodata)->addClass('mlt mlb msr msl');
}
return $stories;
}
示例4: newIntermediateEventNode
public function newIntermediateEventNode(PhabricatorUser $viewer, array $children)
{
$base_uri = new PhutilURI(PhabricatorEnv::getProductionURI('/'));
$domain = $base_uri->getDomain();
// NOTE: For recurring events, all of the events in the series have the
// same UID (the UID of the parent). The child event instances are
// differentiated by the "RECURRENCE-ID" field.
if ($this->isChildEvent()) {
$parent = $this->getParentEvent();
$instance_datetime = PhutilCalendarAbsoluteDateTime::newFromEpoch($this->getUTCInstanceEpoch());
$recurrence_id = $instance_datetime->getISO8601();
$rrule = null;
} else {
$parent = $this;
$recurrence_id = null;
$rrule = $this->newRecurrenceRule();
}
$uid = $parent->getPHID() . '@' . $domain;
$created = $this->getDateCreated();
$created = PhutilCalendarAbsoluteDateTime::newFromEpoch($created);
$modified = $this->getDateModified();
$modified = PhutilCalendarAbsoluteDateTime::newFromEpoch($modified);
$date_start = $this->newStartDateTime();
$date_end = $this->newEndDateTime();
if ($this->getIsAllDay()) {
$date_start->setIsAllDay(true);
$date_end->setIsAllDay(true);
}
$host_phid = $this->getHostPHID();
$invitees = $this->getInvitees();
foreach ($invitees as $key => $invitee) {
if ($invitee->isUninvited()) {
unset($invitees[$key]);
}
}
$phids = array();
$phids[] = $host_phid;
foreach ($invitees as $invitee) {
$phids[] = $invitee->getInviteePHID();
}
$handles = $viewer->loadHandles($phids);
$host_handle = $handles[$host_phid];
$host_name = $host_handle->getFullName();
// NOTE: Gmail shows "Who: Unknown Organizer*" if the organizer URI does
// not look like an email address. Use a synthetic address so it shows
// the host name instead.
$install_uri = PhabricatorEnv::getProductionURI('/');
$install_uri = new PhutilURI($install_uri);
// This should possibly use "metamta.reply-handler-domain" instead, but
// we do not currently accept mail for users anyway, and that option may
// not be configured.
$mail_domain = $install_uri->getDomain();
$host_uri = "mailto:{$host_phid}@{$mail_domain}";
$organizer = id(new PhutilCalendarUserNode())->setName($host_name)->setURI($host_uri);
$attendees = array();
foreach ($invitees as $invitee) {
$invitee_phid = $invitee->getInviteePHID();
$invitee_handle = $handles[$invitee_phid];
$invitee_name = $invitee_handle->getFullName();
$invitee_uri = $invitee_handle->getURI();
$invitee_uri = PhabricatorEnv::getURI($invitee_uri);
switch ($invitee->getStatus()) {
case PhabricatorCalendarEventInvitee::STATUS_ATTENDING:
$status = PhutilCalendarUserNode::STATUS_ACCEPTED;
break;
case PhabricatorCalendarEventInvitee::STATUS_DECLINED:
$status = PhutilCalendarUserNode::STATUS_DECLINED;
break;
case PhabricatorCalendarEventInvitee::STATUS_INVITED:
default:
$status = PhutilCalendarUserNode::STATUS_INVITED;
break;
}
$attendees[] = id(new PhutilCalendarUserNode())->setName($invitee_name)->setURI($invitee_uri)->setStatus($status);
}
// TODO: Use $children to generate EXDATE/RDATE information.
$node = id(new PhutilCalendarEventNode())->setUID($uid)->setName($this->getName())->setDescription($this->getDescription())->setCreatedDateTime($created)->setModifiedDateTime($modified)->setStartDateTime($date_start)->setEndDateTime($date_end)->setOrganizer($organizer)->setAttendees($attendees);
if ($rrule) {
$node->setRecurrenceRule($rrule);
}
if ($recurrence_id) {
$node->setRecurrenceID($recurrence_id);
}
return $node;
}
示例5: newIntermediateEventNode
public function newIntermediateEventNode(PhabricatorUser $viewer)
{
$base_uri = new PhutilURI(PhabricatorEnv::getProductionURI('/'));
$domain = $base_uri->getDomain();
$uid = $this->getPHID() . '@' . $domain;
$created = $this->getDateCreated();
$created = PhutilCalendarAbsoluteDateTime::newFromEpoch($created);
$modified = $this->getDateModified();
$modified = PhutilCalendarAbsoluteDateTime::newFromEpoch($modified);
$date_start = $this->getDateFrom();
$date_start = PhutilCalendarAbsoluteDateTime::newFromEpoch($date_start);
$date_end = $this->getDateTo();
$date_end = PhutilCalendarAbsoluteDateTime::newFromEpoch($date_end);
if ($this->getIsAllDay()) {
$date_start->setIsAllDay(true);
$date_end->setIsAllDay(true);
}
$host_phid = $this->getHostPHID();
$invitees = $this->getInvitees();
foreach ($invitees as $key => $invitee) {
if ($invitee->isUninvited()) {
unset($invitees[$key]);
}
}
$phids = array();
$phids[] = $host_phid;
foreach ($invitees as $invitee) {
$phids[] = $invitee->getInviteePHID();
}
$handles = $viewer->loadHandles($phids);
$host_handle = $handles[$host_phid];
$host_name = $host_handle->getFullName();
$host_uri = $host_handle->getURI();
$host_uri = PhabricatorEnv::getURI($host_uri);
$organizer = id(new PhutilCalendarUserNode())->setName($host_name)->setURI($host_uri);
$attendees = array();
foreach ($invitees as $invitee) {
$invitee_phid = $invitee->getInviteePHID();
$invitee_handle = $handles[$invitee_phid];
$invitee_name = $invitee_handle->getFullName();
$invitee_uri = $invitee_handle->getURI();
$invitee_uri = PhabricatorEnv::getURI($invitee_uri);
switch ($invitee->getStatus()) {
case PhabricatorCalendarEventInvitee::STATUS_ATTENDING:
$status = PhutilCalendarUserNode::STATUS_ACCEPTED;
break;
case PhabricatorCalendarEventInvitee::STATUS_DECLINED:
$status = PhutilCalendarUserNode::STATUS_DECLINED;
break;
case PhabricatorCalendarEventInvitee::STATUS_INVITED:
default:
$status = PhutilCalendarUserNode::STATUS_INVITED;
break;
}
$attendees[] = id(new PhutilCalendarUserNode())->setName($invitee_name)->setURI($invitee_uri)->setStatus($status);
}
$node = id(new PhutilCalendarEventNode())->setUID($uid)->setName($this->getName())->setDescription($this->getDescription())->setCreatedDateTime($created)->setModifiedDateTime($modified)->setStartDateTime($date_start)->setEndDateTime($date_end)->setOrganizer($organizer)->setAttendees($attendees);
return $node;
}