3 abstract class ManiphestTaskRelationship
4 extends PhabricatorObjectRelationship
{
6 public function isEnabledForObject($object) {
7 $viewer = $this->getViewer();
9 $has_app = PhabricatorApplication
::isClassInstalledForViewer(
10 'PhabricatorManiphestApplication',
16 return ($object instanceof ManiphestTask
);
19 protected function newMergeIntoTransactions(ManiphestTask
$task) {
21 id(new ManiphestTransaction())
23 ManiphestTaskMergedIntoTransaction
::TRANSACTIONTYPE
)
24 ->setNewValue($task->getPHID()),
28 protected function newMergeFromTransactions(array $tasks) {
31 $subscriber_phids = $this->loadMergeSubscriberPHIDs($tasks);
33 $xactions[] = id(new ManiphestTransaction())
34 ->setTransactionType(ManiphestTaskMergedFromTransaction
::TRANSACTIONTYPE
)
35 ->setNewValue(mpull($tasks, 'getPHID'));
37 $xactions[] = id(new ManiphestTransaction())
38 ->setTransactionType(PhabricatorTransactions
::TYPE_SUBSCRIBERS
)
39 ->setNewValue(array('+' => $subscriber_phids));
44 private function loadMergeSubscriberPHIDs(array $tasks) {
47 foreach ($tasks as $task) {
48 $phids[] = $task->getAuthorPHID();
49 $phids[] = $task->getOwnerPHID();
52 $subscribers = id(new PhabricatorSubscribersQuery())
53 ->withObjectPHIDs(mpull($tasks, 'getPHID'))
56 foreach ($subscribers as $phid => $subscriber_list) {
57 foreach ($subscriber_list as $subscriber) {
58 $phids[] = $subscriber;
62 $phids = array_unique($phids);
63 $phids = array_filter($phids);