Path: blob/master/src/applications/packages/xaction/publisher/PhabricatorPackagesPublisherKeyTransaction.php
12242 views
<?php12final class PhabricatorPackagesPublisherKeyTransaction3extends PhabricatorPackagesPublisherTransactionType {45const TRANSACTIONTYPE = 'packages.publisher.key';67public function generateOldValue($object) {8return $object->getPublisherKey();9}1011public function applyInternalEffects($object, $value) {12$object->setPublisherKey($value);13}1415public function validateTransactions($object, array $xactions) {16$errors = array();1718if ($this->isEmptyTextTransaction($object->getName(), $xactions)) {19$errors[] = $this->newRequiredError(20pht('Publishers must have a unique publisher key.'));21}2223if (!$this->isNewObject()) {24foreach ($xactions as $xaction) {25$errors[] = $this->newInvalidError(26pht('Once a publisher is created, its key can not be changed.'),27$xaction);28}29}3031foreach ($xactions as $xaction) {32$value = $xaction->getNewValue();33try {34PhabricatorPackagesPublisher::assertValidPublisherKey($value);35} catch (Exception $ex) {36$errors[] = $this->newInvalidError($ex->getMessage(), $xaction);37}38}3940return $errors;41}4243}444546