Correct Aphlict websocket URI construction after PHP8 compatibility changes
[phabricator.git] / src / applications / maniphest / xaction / ManiphestTaskParentTransaction.php
blobd703adc8b52eb521316016037b0d2a36d02b90b0
1 <?php
3 final class ManiphestTaskParentTransaction
4 extends ManiphestTaskTransactionType {
6 const TRANSACTIONTYPE = 'parent';
8 public function generateOldValue($object) {
9 return null;
12 public function shouldHide() {
13 return true;
16 public function applyExternalEffects($object, $value) {
17 $parent_phid = $value;
18 $parent_type = ManiphestTaskDependsOnTaskEdgeType::EDGECONST;
19 $task_phid = $object->getPHID();
21 id(new PhabricatorEdgeEditor())
22 ->addEdge($parent_phid, $parent_type, $task_phid)
23 ->save();
26 public function validateTransactions($object, array $xactions) {
27 $errors = array();
29 $with_effect = array();
30 foreach ($xactions as $xaction) {
31 $task_phid = $xaction->getNewValue();
32 if (!$task_phid) {
33 continue;
36 $with_effect[] = $xaction;
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));
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.'));
58 return $errors;