3 final class AlmanacBindingServiceTransaction
4 extends AlmanacBindingTransactionType
{
6 const TRANSACTIONTYPE
= 'almanac:binding:service';
8 public function generateOldValue($object) {
9 return $object->getServicePHID();
12 public function applyInternalEffects($object, $value) {
13 $object->setServicePHID($value);
16 public function validateTransactions($object, array $xactions) {
19 $service_phid = $object->getServicePHID();
20 if ($this->isEmptyTextTransaction($service_phid, $xactions)) {
21 $errors[] = $this->newRequiredError(
22 pht('Bindings must have a service.'));
25 foreach ($xactions as $xaction) {
26 if (!$this->isNewObject()) {
27 $errors[] = $this->newInvalidError(
29 'The service for a binding can not be changed once it has '.
35 $service_phid = $xaction->getNewValue();
36 $services = id(new AlmanacServiceQuery())
37 ->setViewer($this->getActor())
38 ->withPHIDs(array($service_phid))
41 $errors[] = $this->newInvalidError(
42 pht('You can not bind a nonexistent or restricted service.'),
47 $service = head($services);
48 $can_edit = PhabricatorPolicyFilter
::hasCapability(
51 PhabricatorPolicyCapability
::CAN_EDIT
);
53 $errors[] = $this->newInvalidError(
55 'You can not bind a service which you do not have permission '.