Path: blob/master/src/applications/maniphest/xaction/ManiphestTaskParentTransaction.php
12256 views
<?php12final class ManiphestTaskParentTransaction3extends ManiphestTaskTransactionType {45const TRANSACTIONTYPE = 'parent';67public function generateOldValue($object) {8return null;9}1011public function shouldHide() {12return true;13}1415public function applyExternalEffects($object, $value) {16$parent_phid = $value;17$parent_type = ManiphestTaskDependsOnTaskEdgeType::EDGECONST;18$task_phid = $object->getPHID();1920id(new PhabricatorEdgeEditor())21->addEdge($parent_phid, $parent_type, $task_phid)22->save();23}2425public function validateTransactions($object, array $xactions) {26$errors = array();2728$with_effect = array();29foreach ($xactions as $xaction) {30$task_phid = $xaction->getNewValue();31if (!$task_phid) {32continue;33}3435$with_effect[] = $xaction;3637$task = id(new ManiphestTaskQuery())38->setViewer($this->getActor())39->withPHIDs(array($task_phid))40->executeOne();41if (!$task) {42$errors[] = $this->newInvalidError(43pht(44'Parent task identifier "%s" does not identify a visible '.45'task.',46$task_phid));47}48}4950if ($with_effect && !$this->isNewObject()) {51$errors[] = $this->newInvalidError(52pht(53'You can only select a parent task when creating a '.54'transaction for the first time.'));55}5657return $errors;58}59}606162