Path: blob/master/src/applications/maniphest/relationship/ManiphestTaskRelationship.php
12256 views
<?php12abstract class ManiphestTaskRelationship3extends PhabricatorObjectRelationship {45public function isEnabledForObject($object) {6$viewer = $this->getViewer();78$has_app = PhabricatorApplication::isClassInstalledForViewer(9'PhabricatorManiphestApplication',10$viewer);11if (!$has_app) {12return false;13}1415return ($object instanceof ManiphestTask);16}1718protected function newMergeIntoTransactions(ManiphestTask $task) {19return array(20id(new ManiphestTransaction())21->setTransactionType(22ManiphestTaskMergedIntoTransaction::TRANSACTIONTYPE)23->setNewValue($task->getPHID()),24);25}2627protected function newMergeFromTransactions(array $tasks) {28$xactions = array();2930$subscriber_phids = $this->loadMergeSubscriberPHIDs($tasks);3132$xactions[] = id(new ManiphestTransaction())33->setTransactionType(ManiphestTaskMergedFromTransaction::TRANSACTIONTYPE)34->setNewValue(mpull($tasks, 'getPHID'));3536$xactions[] = id(new ManiphestTransaction())37->setTransactionType(PhabricatorTransactions::TYPE_SUBSCRIBERS)38->setNewValue(array('+' => $subscriber_phids));3940return $xactions;41}4243private function loadMergeSubscriberPHIDs(array $tasks) {44$phids = array();4546foreach ($tasks as $task) {47$phids[] = $task->getAuthorPHID();48$phids[] = $task->getOwnerPHID();49}5051$subscribers = id(new PhabricatorSubscribersQuery())52->withObjectPHIDs(mpull($tasks, 'getPHID'))53->execute();5455foreach ($subscribers as $phid => $subscriber_list) {56foreach ($subscriber_list as $subscriber) {57$phids[] = $subscriber;58}59}6061$phids = array_unique($phids);62$phids = array_filter($phids);6364return $phids;65}6667}686970