Differential D17020 Diff 41522 src/applications/release/xaction/ReleaseChangeRequestRequestedObjectTransaction.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/release/xaction/ReleaseChangeRequestRequestedObjectTransaction.php
- This file was added.
| <?php | |||||
| class ReleaseChangeRequestRequestedObjectTransaction | |||||
| extends ReleaseChangeRequestTransactionType { | |||||
| const TRANSACTIONTYPE = 'change:requestobject'; | |||||
| public function generateOldValue($object) { | |||||
| return $object->getRequestedObjectPHID(); | |||||
| } | |||||
| public function applyInternalEffects($object, $value) { | |||||
| $object->setRequestedObjectPHID($value); | |||||
| } | |||||
| public function shouldHide() { | |||||
| return true; | |||||
| } | |||||
| public function validateTransactions($object, array $xactions) { | |||||
| $errors = $this->validateRequiredFieldTransactions( | |||||
| $object, | |||||
| $xactions, | |||||
| pht('Requested Object')); | |||||
| $viewer = $this->getActor(); | |||||
| foreach ($xactions as $xaction) { | |||||
| $object_phid = $xaction->getNewValue(); | |||||
| $target_object = id(new PhabricatorObjectQuery()) | |||||
| ->setViewer($viewer) | |||||
| ->withPHIDs(array($object_phid)) | |||||
| ->setRaisePolicyExceptions(false) | |||||
| ->requireCapabilities( | |||||
| array( | |||||
| PhabricatorPolicyCapability::CAN_VIEW, | |||||
| )) | |||||
| ->executeOne(); | |||||
| if (!$target_object) { | |||||
| $errors[] = $this->newInvalidError( | |||||
| pht( | |||||
| 'Requested object "%s" is invalid: the object must exist and you '. | |||||
| 'must have permission to view it in order to create a new Change'. | |||||
| 'Request.', | |||||
| $object_phid), | |||||
| $xaction); | |||||
| } | |||||
| } | |||||
| return $errors; | |||||
| } | |||||
| } | |||||