mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-15 19:32:40 +01:00
d6a620be45
Summary: Ref T12671. This modernized Maniphest transactions to modular transactions. Test Plan: - Create Task - Edit Task - Raise Priority - Change Status - Merge as a duplicate - Create Subtask - Claim Task - Assign Project - Move on Workboard - Set a cover image - Assign story points - Change story points - Generate lots via lipsum - Bulk edit tasks - Leave comments - Award Token I'm sure I'm missing something. Reviewers: epriestley Reviewed By: epriestley Subscribers: hazelyang, Korvin Maniphest Tasks: T12671 Differential Revision: https://secure.phabricator.com/D17844
69 lines
1.8 KiB
PHP
69 lines
1.8 KiB
PHP
<?php
|
|
|
|
abstract class ManiphestTaskRelationship
|
|
extends PhabricatorObjectRelationship {
|
|
|
|
public function isEnabledForObject($object) {
|
|
$viewer = $this->getViewer();
|
|
|
|
$has_app = PhabricatorApplication::isClassInstalledForViewer(
|
|
'PhabricatorManiphestApplication',
|
|
$viewer);
|
|
if (!$has_app) {
|
|
return false;
|
|
}
|
|
|
|
return ($object instanceof ManiphestTask);
|
|
}
|
|
|
|
protected function newMergeIntoTransactions(ManiphestTask $task) {
|
|
return array(
|
|
id(new ManiphestTransaction())
|
|
->setTransactionType(
|
|
ManiphestTaskMergedIntoTransaction::TRANSACTIONTYPE)
|
|
->setNewValue($task->getPHID()),
|
|
);
|
|
}
|
|
|
|
protected function newMergeFromTransactions(array $tasks) {
|
|
$xactions = array();
|
|
|
|
$subscriber_phids = $this->loadMergeSubscriberPHIDs($tasks);
|
|
|
|
$xactions[] = id(new ManiphestTransaction())
|
|
->setTransactionType(PhabricatorTransactions::TYPE_SUBSCRIBERS)
|
|
->setNewValue(array('+' => $subscriber_phids));
|
|
|
|
$xactions[] = id(new ManiphestTransaction())
|
|
->setTransactionType(
|
|
ManiphestTaskMergedFromTransaction::TRANSACTIONTYPE)
|
|
->setNewValue(mpull($tasks, 'getPHID'));
|
|
|
|
return $xactions;
|
|
}
|
|
|
|
private function loadMergeSubscriberPHIDs(array $tasks) {
|
|
$phids = array();
|
|
|
|
foreach ($tasks as $task) {
|
|
$phids[] = $task->getAuthorPHID();
|
|
$phids[] = $task->getOwnerPHID();
|
|
}
|
|
|
|
$subscribers = id(new PhabricatorSubscribersQuery())
|
|
->withObjectPHIDs(mpull($tasks, 'getPHID'))
|
|
->execute();
|
|
|
|
foreach ($subscribers as $phid => $subscriber_list) {
|
|
foreach ($subscriber_list as $subscriber) {
|
|
$phids[] = $subscriber;
|
|
}
|
|
}
|
|
|
|
$phids = array_unique($phids);
|
|
$phids = array_filter($phids);
|
|
|
|
return $phids;
|
|
}
|
|
|
|
}
|