コード例 #1
0
 protected function applyCustomExternalTransaction(PhabricatorLiskDAO $object, PhabricatorApplicationTransaction $xaction)
 {
     switch ($xaction->getTransactionType()) {
         case AlmanacBindingTransaction::TYPE_DISABLE:
             return;
         case AlmanacBindingTransaction::TYPE_INTERFACE:
             $interface_phids = array();
             $interface_phids[] = $xaction->getOldValue();
             $interface_phids[] = $xaction->getNewValue();
             $interface_phids = array_filter($interface_phids);
             $interface_phids = array_unique($interface_phids);
             $interfaces = id(new AlmanacInterfaceQuery())->setViewer(PhabricatorUser::getOmnipotentUser())->withPHIDs($interface_phids)->execute();
             $device_phids = array();
             foreach ($interfaces as $interface) {
                 $device_phids[] = $interface->getDevicePHID();
             }
             $device_phids = array_unique($device_phids);
             $devices = id(new AlmanacDeviceQuery())->setViewer(PhabricatorUser::getOmnipotentUser())->withPHIDs($device_phids)->execute();
             foreach ($devices as $device) {
                 $device->rebuildClusterBindingStatus();
             }
             return;
     }
     return parent::applyCustomExternalTransaction($object, $xaction);
 }
コード例 #2
0
 protected function applyCustomExternalTransaction(PhabricatorLiskDAO $object, PhabricatorApplicationTransaction $xaction)
 {
     switch ($xaction->getTransactionType()) {
         case AlmanacDeviceTransaction::TYPE_NAME:
             return;
         case AlmanacDeviceTransaction::TYPE_INTERFACE:
             $old = $xaction->getOldValue();
             if ($old) {
                 $interface = id(new AlmanacInterfaceQuery())->setViewer($this->requireActor())->withIDs(array($old['id']))->executeOne();
                 if (!$interface) {
                     throw new Exception(pht('Unable to load interface!'));
                 }
             } else {
                 $interface = AlmanacInterface::initializeNewInterface()->setDevicePHID($object->getPHID());
             }
             $new = $xaction->getNewValue();
             if ($new) {
                 $interface->setNetworkPHID($new['networkPHID'])->setAddress($new['address'])->setPort((int) $new['port']);
                 if (idx($new, 'phid')) {
                     $interface->setPHID($new['phid']);
                 }
                 $interface->save();
             } else {
                 $interface->delete();
             }
             return;
     }
     return parent::applyCustomExternalTransaction($object, $xaction);
 }
コード例 #3
0
 protected function applyCustomExternalTransaction(PhabricatorLiskDAO $object, PhabricatorApplicationTransaction $xaction)
 {
     switch ($xaction->getTransactionType()) {
         case AlmanacServiceTransaction::TYPE_NAME:
             return;
     }
     return parent::applyCustomExternalTransaction($object, $xaction);
 }