Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/maniphest/xaction/ManiphestTaskParentTransaction.php
12256 views
1
<?php
2
3
final class ManiphestTaskParentTransaction
4
extends ManiphestTaskTransactionType {
5
6
const TRANSACTIONTYPE = 'parent';
7
8
public function generateOldValue($object) {
9
return null;
10
}
11
12
public function shouldHide() {
13
return true;
14
}
15
16
public function applyExternalEffects($object, $value) {
17
$parent_phid = $value;
18
$parent_type = ManiphestTaskDependsOnTaskEdgeType::EDGECONST;
19
$task_phid = $object->getPHID();
20
21
id(new PhabricatorEdgeEditor())
22
->addEdge($parent_phid, $parent_type, $task_phid)
23
->save();
24
}
25
26
public function validateTransactions($object, array $xactions) {
27
$errors = array();
28
29
$with_effect = array();
30
foreach ($xactions as $xaction) {
31
$task_phid = $xaction->getNewValue();
32
if (!$task_phid) {
33
continue;
34
}
35
36
$with_effect[] = $xaction;
37
38
$task = id(new ManiphestTaskQuery())
39
->setViewer($this->getActor())
40
->withPHIDs(array($task_phid))
41
->executeOne();
42
if (!$task) {
43
$errors[] = $this->newInvalidError(
44
pht(
45
'Parent task identifier "%s" does not identify a visible '.
46
'task.',
47
$task_phid));
48
}
49
}
50
51
if ($with_effect && !$this->isNewObject()) {
52
$errors[] = $this->newInvalidError(
53
pht(
54
'You can only select a parent task when creating a '.
55
'transaction for the first time.'));
56
}
57
58
return $errors;
59
}
60
}
61
62