Changeset View
Changeset View
Standalone View
Standalone View
src/applications/almanac/editor/AlmanacBindingEditor.php
<?php | <?php | ||||
final class AlmanacBindingEditor | final class AlmanacBindingEditor | ||||
extends AlmanacEditor { | extends AlmanacEditor { | ||||
private $devicePHID; | |||||
public function getEditorObjectsDescription() { | public function getEditorObjectsDescription() { | ||||
return pht('Almanac Binding'); | return pht('Almanac Binding'); | ||||
} | } | ||||
public function getTransactionTypes() { | public function getTransactionTypes() { | ||||
$types = parent::getTransactionTypes(); | $types = parent::getTransactionTypes(); | ||||
$types[] = AlmanacBindingTransaction::TYPE_INTERFACE; | $types[] = AlmanacBindingTransaction::TYPE_INTERFACE; | ||||
▲ Show 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | final class AlmanacBindingEditor | ||||
} | } | ||||
protected function applyCustomExternalTransaction( | protected function applyCustomExternalTransaction( | ||||
PhabricatorLiskDAO $object, | PhabricatorLiskDAO $object, | ||||
PhabricatorApplicationTransaction $xaction) { | PhabricatorApplicationTransaction $xaction) { | ||||
switch ($xaction->getTransactionType()) { | switch ($xaction->getTransactionType()) { | ||||
case AlmanacBindingTransaction::TYPE_INTERFACE: | 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; | ||||
} | } | ||||
return parent::applyCustomExternalTransaction($object, $xaction); | return parent::applyCustomExternalTransaction($object, $xaction); | ||||
} | } | ||||
protected function validateTransaction( | protected function validateTransaction( | ||||
PhabricatorLiskDAO $object, | PhabricatorLiskDAO $object, | ||||
▲ Show 20 Lines • Show All 63 Lines • Show Last 20 Lines |