2012-12-11 23:00:21 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @concrete-extensible
|
|
|
|
*/
|
|
|
|
class PhabricatorApplicationTransactionFeedStory
|
|
|
|
extends PhabricatorFeedStory {
|
|
|
|
|
|
|
|
public function getPrimaryObjectPHID() {
|
|
|
|
return $this->getValue('objectPHID');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getRequiredObjectPHIDs() {
|
2013-11-05 18:03:59 +01:00
|
|
|
return $this->getValue('transactionPHIDs');
|
2012-12-11 23:00:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getRequiredHandlePHIDs() {
|
|
|
|
$phids = array();
|
2013-11-05 18:03:59 +01:00
|
|
|
$phids[] = $this->getValue('objectPHID');
|
|
|
|
foreach ($this->getValue('transactionPHIDs') as $xaction_phid) {
|
|
|
|
$xaction = $this->getObject($xaction_phid);
|
|
|
|
foreach ($xaction->getRequiredHandlePHIDs() as $handle_phid) {
|
|
|
|
$phids[] = $handle_phid;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $phids;
|
2012-12-11 23:00:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
protected function getPrimaryTransactionPHID() {
|
|
|
|
return head($this->getValue('transactionPHIDs'));
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function getPrimaryTransaction() {
|
|
|
|
return $this->getObject($this->getPrimaryTransactionPHID());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function renderView() {
|
2013-07-13 02:04:02 +02:00
|
|
|
$view = $this->newStoryView();
|
2012-12-11 23:00:21 +01:00
|
|
|
|
2013-05-26 16:54:29 +02:00
|
|
|
$handle = $this->getHandle($this->getPrimaryObjectPHID());
|
|
|
|
$view->setHref($handle->getURI());
|
|
|
|
|
|
|
|
$view->setAppIconFromPHID($handle->getPHID());
|
2012-12-11 23:00:21 +01:00
|
|
|
|
|
|
|
$xaction_phids = $this->getValue('transactionPHIDs');
|
2013-11-05 18:03:59 +01:00
|
|
|
$xaction = $this->getPrimaryTransaction();
|
2012-12-11 23:00:21 +01:00
|
|
|
|
|
|
|
$xaction->setHandles($this->getHandles());
|
2013-09-19 00:15:25 +02:00
|
|
|
$view->setTitle($xaction->getTitleForFeed($this));
|
2013-11-05 18:03:59 +01:00
|
|
|
|
|
|
|
foreach ($xaction_phids as $xaction_phid) {
|
|
|
|
$secondary_xaction = $this->getObject($xaction_phid);
|
|
|
|
$secondary_xaction->setHandles($this->getHandles());
|
|
|
|
|
|
|
|
$body = $secondary_xaction->getBodyForFeed($this);
|
|
|
|
if (nonempty($body)) {
|
|
|
|
$view->appendChild($body);
|
|
|
|
}
|
2013-08-05 19:10:33 +02:00
|
|
|
}
|
2012-12-11 23:00:21 +01:00
|
|
|
|
2013-05-26 16:54:29 +02:00
|
|
|
$view->setImage(
|
2013-11-05 18:03:59 +01:00
|
|
|
$this->getHandle($xaction->getAuthorPHID())->getImageURI());
|
2013-05-26 16:54:29 +02:00
|
|
|
|
2012-12-11 23:00:21 +01:00
|
|
|
return $view;
|
|
|
|
}
|
|
|
|
|
2013-02-16 02:10:51 +01:00
|
|
|
public function renderText() {
|
2014-04-10 22:46:02 +02:00
|
|
|
$xaction = $this->getPrimaryTransaction();
|
|
|
|
$old_target = $xaction->getRenderingTarget();
|
|
|
|
$new_target = PhabricatorApplicationTransaction::TARGET_TEXT;
|
|
|
|
$xaction->setRenderingTarget($new_target);
|
|
|
|
$text = $xaction->getTitleForFeed($this);
|
|
|
|
$xaction->setRenderingTarget($old_target);
|
|
|
|
return $text;
|
2013-02-16 02:10:51 +01:00
|
|
|
}
|
|
|
|
|
2012-12-11 23:00:21 +01:00
|
|
|
}
|