Differential D19179 Diff 45940 src/applications/transactions/feed/PhabricatorApplicationTransactionFeedStory.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/transactions/feed/PhabricatorApplicationTransactionFeedStory.php
<?php | <?php | ||||
/** | /** | ||||
* @concrete-extensible | * @concrete-extensible | ||||
*/ | */ | ||||
class PhabricatorApplicationTransactionFeedStory | class PhabricatorApplicationTransactionFeedStory | ||||
extends PhabricatorFeedStory { | extends PhabricatorFeedStory { | ||||
private $primaryTransactionPHID; | |||||
public function getPrimaryObjectPHID() { | public function getPrimaryObjectPHID() { | ||||
return $this->getValue('objectPHID'); | return $this->getValue('objectPHID'); | ||||
} | } | ||||
public function getRequiredObjectPHIDs() { | public function getRequiredObjectPHIDs() { | ||||
return $this->getValue('transactionPHIDs'); | return $this->getValue('transactionPHIDs'); | ||||
} | } | ||||
public function getRequiredHandlePHIDs() { | public function getRequiredHandlePHIDs() { | ||||
$phids = array(); | $phids = array(); | ||||
$phids[] = $this->getValue('objectPHID'); | $phids[] = $this->getValue('objectPHID'); | ||||
foreach ($this->getValue('transactionPHIDs') as $xaction_phid) { | foreach ($this->getValue('transactionPHIDs') as $xaction_phid) { | ||||
$xaction = $this->getObject($xaction_phid); | $xaction = $this->getObject($xaction_phid); | ||||
foreach ($xaction->getRequiredHandlePHIDs() as $handle_phid) { | foreach ($xaction->getRequiredHandlePHIDs() as $handle_phid) { | ||||
$phids[] = $handle_phid; | $phids[] = $handle_phid; | ||||
} | } | ||||
} | } | ||||
return $phids; | return $phids; | ||||
} | } | ||||
protected function getPrimaryTransactionPHID() { | protected function getPrimaryTransactionPHID() { | ||||
return head($this->getValue('transactionPHIDs')); | if ($this->primaryTransactionPHID === null) { | ||||
// Transactions are filtered and sorted before they're stored, but the | |||||
// rendering logic can change between the time an edit occurs and when | |||||
// we actually render the story. Recalculate the filtering at display | |||||
// time because it's cheap and gets us better results when things change | |||||
// by letting the changes apply retroactively. | |||||
$xaction_phids = $this->getValue('transactionPHIDs'); | |||||
$xactions = array(); | |||||
foreach ($xaction_phids as $xaction_phid) { | |||||
$xactions[] = $this->getObject($xaction_phid); | |||||
} | |||||
foreach ($xactions as $key => $xaction) { | |||||
if ($xaction->shouldHideForFeed()) { | |||||
unset($xactions[$key]); | |||||
} | |||||
} | |||||
if ($xactions) { | |||||
$primary_phid = head($xactions)->getPHID(); | |||||
} else { | |||||
$primary_phid = head($xaction_phids); | |||||
} | |||||
$this->primaryTransactionPHID = $primary_phid; | |||||
} | |||||
return $this->primaryTransactionPHID; | |||||
} | } | ||||
public function getPrimaryTransaction() { | public function getPrimaryTransaction() { | ||||
return $this->getObject($this->getPrimaryTransactionPHID()); | return $this->getObject($this->getPrimaryTransactionPHID()); | ||||
} | } | ||||
public function getFieldStoryMarkupFields() { | public function getFieldStoryMarkupFields() { | ||||
$xaction_phids = $this->getValue('transactionPHIDs'); | $xaction_phids = $this->getValue('transactionPHIDs'); | ||||
▲ Show 20 Lines • Show All 133 Lines • Show Last 20 Lines |