2013-02-19 02:44:45 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class PhabricatorTokenGivenFeedStory
|
|
|
|
extends PhabricatorFeedStory {
|
|
|
|
|
|
|
|
public function getPrimaryObjectPHID() {
|
|
|
|
return $this->getValue('objectPHID');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getRequiredHandlePHIDs() {
|
|
|
|
$phids = array();
|
|
|
|
$phids[] = $this->getValue('objectPHID');
|
|
|
|
$phids[] = $this->getValue('authorPHID');
|
|
|
|
return $phids;
|
|
|
|
}
|
|
|
|
|
2013-09-25 02:00:31 +02:00
|
|
|
public function getRequiredObjectPHIDs() {
|
|
|
|
$phids = array();
|
|
|
|
$phids[] = $this->getValue('tokenPHID');
|
|
|
|
return $phids;
|
|
|
|
}
|
|
|
|
|
2013-02-19 02:44:45 +01:00
|
|
|
public function renderView() {
|
2013-07-13 02:04:02 +02:00
|
|
|
$view = $this->newStoryView();
|
2013-04-13 18:09:42 +02:00
|
|
|
$view->setAppIcon('token-dark');
|
|
|
|
$author_phid = $this->getValue('authorPHID');
|
2013-02-19 02:44:45 +01:00
|
|
|
|
|
|
|
$href = $this->getHandle($this->getPrimaryObjectPHID())->getURI();
|
2013-02-21 23:24:53 +01:00
|
|
|
$view->setHref($href);
|
2013-02-19 02:44:45 +01:00
|
|
|
|
2014-04-10 22:46:02 +02:00
|
|
|
$view->setTitle($this->renderTitle());
|
|
|
|
$view->setImage($this->getHandle($author_phid)->getImageURI());
|
|
|
|
|
|
|
|
return $view;
|
|
|
|
}
|
2013-09-25 02:00:31 +02:00
|
|
|
|
2014-04-10 22:46:02 +02:00
|
|
|
private function renderTitle() {
|
|
|
|
$token = $this->getObject($this->getValue('tokenPHID'));
|
2013-02-19 02:44:45 +01:00
|
|
|
$title = pht(
|
2013-09-25 02:00:31 +02:00
|
|
|
'%s awarded %s a %s token.',
|
2013-02-19 02:44:45 +01:00
|
|
|
$this->linkTo($this->getValue('authorPHID')),
|
2013-09-25 02:00:31 +02:00
|
|
|
$this->linkTo($this->getValue('objectPHID')),
|
|
|
|
$token->getName());
|
2013-02-19 02:44:45 +01:00
|
|
|
|
2014-04-10 22:46:02 +02:00
|
|
|
return $title;
|
2013-02-19 02:44:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function renderText() {
|
2014-04-10 22:46:02 +02:00
|
|
|
$old_target = $this->getRenderingTarget();
|
|
|
|
$this->setRenderingTarget(PhabricatorApplicationTransaction::TARGET_TEXT);
|
|
|
|
$title = $this->renderTitle();
|
|
|
|
$this->setRenderingTarget($old_target);
|
|
|
|
return $title;
|
2013-02-19 02:44:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|