Differential D21815 Diff 52023 src/applications/project/xaction/PhabricatorProjectImageTransaction.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/project/xaction/PhabricatorProjectImageTransaction.php
<?php | <?php | ||||
final class PhabricatorProjectImageTransaction | final class PhabricatorProjectImageTransaction | ||||
extends PhabricatorProjectTransactionType { | extends PhabricatorProjectTransactionType { | ||||
const TRANSACTIONTYPE = 'project:image'; | const TRANSACTIONTYPE = 'project:image'; | ||||
public function generateOldValue($object) { | public function generateOldValue($object) { | ||||
return $object->getProfileImagePHID(); | return $object->getProfileImagePHID(); | ||||
} | } | ||||
public function applyInternalEffects($object, $value) { | public function applyInternalEffects($object, $value) { | ||||
$object->setProfileImagePHID($value); | $object->setProfileImagePHID($value); | ||||
} | } | ||||
public function applyExternalEffects($object, $value) { | |||||
$old = $this->getOldValue(); | |||||
$new = $value; | |||||
$all = array(); | |||||
if ($old) { | |||||
$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()); | |||||
} | |||||
} | |||||
public function getTitle() { | public function getTitle() { | ||||
$old = $this->getOldValue(); | $old = $this->getOldValue(); | ||||
$new = $this->getNewValue(); | $new = $this->getNewValue(); | ||||
// TODO: Some day, it would be nice to show the images. | // TODO: Some day, it would be nice to show the images. | ||||
if (!$old) { | if (!$old) { | ||||
return pht( | return pht( | ||||
"%s set this project's image to %s.", | "%s set this project's image to %s.", | ||||
▲ Show 20 Lines • Show All 85 Lines • Show Last 20 Lines |