Changeset View
Changeset View
Standalone View
Standalone View
src/applications/macro/xaction/PhabricatorMacroAudioTransaction.php
<?php | <?php | ||||
final class PhabricatorMacroAudioTransaction | final class PhabricatorMacroAudioTransaction | ||||
extends PhabricatorMacroTransactionType { | extends PhabricatorMacroTransactionType { | ||||
const TRANSACTIONTYPE = 'macro:audio'; | const TRANSACTIONTYPE = 'macro:audio'; | ||||
public function generateOldValue($object) { | public function generateOldValue($object) { | ||||
return $object->getAudioPHID(); | return $object->getAudioPHID(); | ||||
} | } | ||||
public function applyInternalEffects($object, $value) { | public function applyInternalEffects($object, $value) { | ||||
$object->setAudioPHID($value); | $object->setAudioPHID($value); | ||||
} | } | ||||
public function applyExternalEffects($object, $value) { | public function extractFilePHIDs($object, $value) { | ||||
$old = $this->generateOldValue($object); | $file_phids = array(); | ||||
$new = $value; | |||||
$all = array(); | if ($value) { | ||||
if ($old) { | $file_phids[] = $value; | ||||
$all[] = $old; | |||||
} | |||||
if ($new) { | |||||
$all[] = $new; | |||||
} | |||||
$files = id(new PhabricatorFileQuery()) | |||||
->setViewer($this->getActor()) | |||||
->withPHIDs($all) | |||||
->execute(); | |||||
$files = mpull($files, null, 'getPHID'); | |||||
$old_file = idx($files, $old); | |||||
if ($old_file) { | |||||
$old_file->detachFromObject($object->getPHID()); | |||||
} | |||||
$new_file = idx($files, $new); | |||||
if ($new_file) { | |||||
$new_file->attachToObject($object->getPHID()); | |||||
} | } | ||||
return $file_phids; | |||||
} | } | ||||
public function getTitle() { | public function getTitle() { | ||||
$new = $this->getNewValue(); | $new = $this->getNewValue(); | ||||
$old = $this->getOldValue(); | $old = $this->getOldValue(); | ||||
if (!$old) { | if (!$old) { | ||||
return pht( | return pht( | ||||
'%s attached audio: %s.', | '%s attached audio: %s.', | ||||
Show All 35 Lines |