Remove product literal strings in "pht()", part 8
[phabricator.git] / src / applications / maniphest / relationship / ManiphestTaskRelationship.php
bloba7d3e6f11c91599549afff5423d2b986adb1fec0
1 <?php
3 abstract class ManiphestTaskRelationship
4 extends PhabricatorObjectRelationship {
6 public function isEnabledForObject($object) {
7 $viewer = $this->getViewer();
9 $has_app = PhabricatorApplication::isClassInstalledForViewer(
10 'PhabricatorManiphestApplication',
11 $viewer);
12 if (!$has_app) {
13 return false;
16 return ($object instanceof ManiphestTask);
19 protected function newMergeIntoTransactions(ManiphestTask $task) {
20 return array(
21 id(new ManiphestTransaction())
22 ->setTransactionType(
23 ManiphestTaskMergedIntoTransaction::TRANSACTIONTYPE)
24 ->setNewValue($task->getPHID()),
28 protected function newMergeFromTransactions(array $tasks) {
29 $xactions = array();
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));
41 return $xactions;
44 private function loadMergeSubscriberPHIDs(array $tasks) {
45 $phids = array();
47 foreach ($tasks as $task) {
48 $phids[] = $task->getAuthorPHID();
49 $phids[] = $task->getOwnerPHID();
52 $subscribers = id(new PhabricatorSubscribersQuery())
53 ->withObjectPHIDs(mpull($tasks, 'getPHID'))
54 ->execute();
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);
65 return $phids;