Page MenuHomePhabricator

D17954.id43182.diff
No OneTemporary

D17954.id43182.diff

diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -3621,6 +3621,7 @@
'PhabricatorProjectHovercardEngineExtension' => 'applications/project/engineextension/PhabricatorProjectHovercardEngineExtension.php',
'PhabricatorProjectIconSet' => 'applications/project/icon/PhabricatorProjectIconSet.php',
'PhabricatorProjectIconsConfigOptionType' => 'applications/project/config/PhabricatorProjectIconsConfigOptionType.php',
+ 'PhabricatorProjectImageTransaction' => 'applications/project/xaction/PhabricatorProjectImageTransaction.php',
'PhabricatorProjectInterface' => 'applications/project/interface/PhabricatorProjectInterface.php',
'PhabricatorProjectListController' => 'applications/project/controller/PhabricatorProjectListController.php',
'PhabricatorProjectListView' => 'applications/project/view/PhabricatorProjectListView.php',
@@ -9035,6 +9036,7 @@
'PhabricatorProjectHovercardEngineExtension' => 'PhabricatorHovercardEngineExtension',
'PhabricatorProjectIconSet' => 'PhabricatorIconSet',
'PhabricatorProjectIconsConfigOptionType' => 'PhabricatorConfigJSONOptionType',
+ 'PhabricatorProjectImageTransaction' => 'PhabricatorProjectTransactionType',
'PhabricatorProjectListController' => 'PhabricatorProjectController',
'PhabricatorProjectListView' => 'AphrontView',
'PhabricatorProjectLockController' => 'PhabricatorProjectController',
diff --git a/src/applications/files/controller/PhabricatorFileComposeController.php b/src/applications/files/controller/PhabricatorFileComposeController.php
--- a/src/applications/files/controller/PhabricatorFileComposeController.php
+++ b/src/applications/files/controller/PhabricatorFileComposeController.php
@@ -48,7 +48,8 @@
$xactions = array();
$xactions[] = id(new PhabricatorProjectTransaction())
- ->setTransactionType(PhabricatorProjectTransaction::TYPE_IMAGE)
+ ->setTransactionType(
+ PhabricatorProjectImageTransaction::TRANSACTIONTYPE)
->setNewValue($file->getPHID());
$editor = id(new PhabricatorProjectTransactionEditor())
diff --git a/src/applications/project/controller/PhabricatorProjectEditPictureController.php b/src/applications/project/controller/PhabricatorProjectEditPictureController.php
--- a/src/applications/project/controller/PhabricatorProjectEditPictureController.php
+++ b/src/applications/project/controller/PhabricatorProjectEditPictureController.php
@@ -78,7 +78,8 @@
$xactions = array();
$xactions[] = id(new PhabricatorProjectTransaction())
- ->setTransactionType(PhabricatorProjectTransaction::TYPE_IMAGE)
+ ->setTransactionType(
+ PhabricatorProjectImageTransaction::TRANSACTIONTYPE)
->setNewValue($new_value);
$editor = id(new PhabricatorProjectTransactionEditor())
diff --git a/src/applications/project/editor/PhabricatorProjectTransactionEditor.php b/src/applications/project/editor/PhabricatorProjectTransactionEditor.php
--- a/src/applications/project/editor/PhabricatorProjectTransactionEditor.php
+++ b/src/applications/project/editor/PhabricatorProjectTransactionEditor.php
@@ -30,7 +30,6 @@
$types[] = PhabricatorTransactions::TYPE_EDIT_POLICY;
$types[] = PhabricatorTransactions::TYPE_JOIN_POLICY;
- $types[] = PhabricatorProjectTransaction::TYPE_IMAGE;
$types[] = PhabricatorProjectTransaction::TYPE_ICON;
$types[] = PhabricatorProjectTransaction::TYPE_COLOR;
$types[] = PhabricatorProjectTransaction::TYPE_LOCKED;
@@ -49,8 +48,6 @@
PhabricatorApplicationTransaction $xaction) {
switch ($xaction->getTransactionType()) {
- case PhabricatorProjectTransaction::TYPE_IMAGE:
- return $object->getProfileImagePHID();
case PhabricatorProjectTransaction::TYPE_ICON:
return $object->getIcon();
case PhabricatorProjectTransaction::TYPE_COLOR:
@@ -78,7 +75,6 @@
PhabricatorApplicationTransaction $xaction) {
switch ($xaction->getTransactionType()) {
- case PhabricatorProjectTransaction::TYPE_IMAGE:
case PhabricatorProjectTransaction::TYPE_ICON:
case PhabricatorProjectTransaction::TYPE_COLOR:
case PhabricatorProjectTransaction::TYPE_LOCKED:
@@ -105,9 +101,6 @@
PhabricatorApplicationTransaction $xaction) {
switch ($xaction->getTransactionType()) {
- case PhabricatorProjectTransaction::TYPE_IMAGE:
- $object->setProfileImagePHID($xaction->getNewValue());
- return;
case PhabricatorProjectTransaction::TYPE_ICON:
$object->setIcon($xaction->getNewValue());
return;
@@ -150,7 +143,6 @@
$new = $xaction->getNewValue();
switch ($xaction->getTransactionType()) {
- case PhabricatorProjectTransaction::TYPE_IMAGE:
case PhabricatorProjectTransaction::TYPE_ICON:
case PhabricatorProjectTransaction::TYPE_COLOR:
case PhabricatorProjectTransaction::TYPE_LOCKED:
@@ -336,7 +328,7 @@
switch ($xaction->getTransactionType()) {
case PhabricatorProjectNameTransaction::TRANSACTIONTYPE:
case PhabricatorProjectStatusTransaction::TRANSACTIONTYPE:
- case PhabricatorProjectTransaction::TYPE_IMAGE:
+ case PhabricatorProjectImageTransaction::TRANSACTIONTYPE:
case PhabricatorProjectTransaction::TYPE_ICON:
case PhabricatorProjectTransaction::TYPE_COLOR:
PhabricatorPolicyFilter::requireCapability(
@@ -475,22 +467,6 @@
return true;
}
- protected function extractFilePHIDsFromCustomTransaction(
- PhabricatorLiskDAO $object,
- PhabricatorApplicationTransaction $xaction) {
-
- switch ($xaction->getTransactionType()) {
- case PhabricatorProjectTransaction::TYPE_IMAGE:
- $new = $xaction->getNewValue();
- if ($new) {
- return array($new);
- }
- break;
- }
-
- return parent::extractFilePHIDsFromCustomTransaction($object, $xaction);
- }
-
protected function applyFinalEffects(
PhabricatorLiskDAO $object,
array $xactions) {
diff --git a/src/applications/project/storage/PhabricatorProjectTransaction.php b/src/applications/project/storage/PhabricatorProjectTransaction.php
--- a/src/applications/project/storage/PhabricatorProjectTransaction.php
+++ b/src/applications/project/storage/PhabricatorProjectTransaction.php
@@ -3,7 +3,6 @@
final class PhabricatorProjectTransaction
extends PhabricatorModularTransaction {
- const TYPE_IMAGE = 'project:image';
const TYPE_ICON = 'project:icon';
const TYPE_COLOR = 'project:color';
const TYPE_LOCKED = 'project:locked';
@@ -45,10 +44,6 @@
$rem = array_diff($old, $new);
$req_phids = array_merge($add, $rem);
break;
- case self::TYPE_IMAGE:
- $req_phids[] = $old;
- $req_phids[] = $new;
- break;
}
return array_merge($req_phids, parent::getRequiredHandlePHIDs());
@@ -106,8 +101,6 @@
}
case self::TYPE_ICON:
return PhabricatorProjectIconSet::getIconIcon($new);
- case self::TYPE_IMAGE:
- return 'fa-photo';
case self::TYPE_MEMBERS:
return 'fa-user';
}
@@ -126,26 +119,6 @@
'%s created this project.',
$this->renderHandleLink($author_phid));
- case self::TYPE_IMAGE:
- // TODO: Some day, it would be nice to show the images.
- if (!$old) {
- return pht(
- "%s set this project's image to %s.",
- $author_handle,
- $this->renderHandleLink($new));
- } else if (!$new) {
- return pht(
- "%s removed this project's image.",
- $author_handle);
- } else {
- return pht(
- "%s updated this project's image from %s to %s.",
- $author_handle,
- $this->renderHandleLink($old),
- $this->renderHandleLink($new));
- }
- break;
-
case self::TYPE_ICON:
$set = new PhabricatorProjectIconSet();
@@ -253,27 +226,6 @@
$new = $this->getNewValue();
switch ($this->getTransactionType()) {
- case self::TYPE_IMAGE:
- // TODO: Some day, it would be nice to show the images.
- if (!$old) {
- return pht(
- '%s set the image for %s to %s.',
- $author_handle,
- $object_handle,
- $this->renderHandleLink($new));
- } else if (!$new) {
- return pht(
- '%s removed the image for %s.',
- $author_handle,
- $object_handle);
- } else {
- return pht(
- '%s updated the image for %s from %s to %s.',
- $author_handle,
- $object_handle,
- $this->renderHandleLink($old),
- $this->renderHandleLink($new));
- }
case self::TYPE_ICON:
$set = new PhabricatorProjectIconSet();
@@ -313,7 +265,7 @@
switch ($this->getTransactionType()) {
case PhabricatorProjectNameTransaction::TRANSACTIONTYPE:
case PhabricatorProjectSlugsTransaction::TRANSACTIONTYPE:
- case self::TYPE_IMAGE:
+ case PhabricatorProjectImageTransaction::TRANSACTIONTYPE:
case self::TYPE_ICON:
case self::TYPE_COLOR:
$tags[] = self::MAILTAG_METADATA;
diff --git a/src/applications/project/xaction/PhabricatorProjectImageTransaction.php b/src/applications/project/xaction/PhabricatorProjectImageTransaction.php
new file mode 100644
--- /dev/null
+++ b/src/applications/project/xaction/PhabricatorProjectImageTransaction.php
@@ -0,0 +1,75 @@
+<?php
+
+final class PhabricatorProjectImageTransaction
+ extends PhabricatorProjectTransactionType {
+
+ const TRANSACTIONTYPE = 'project:image';
+
+ public function generateOldValue($object) {
+ return $object->getProfileImagePHID();
+ }
+
+ public function applyInternalEffects($object, $value) {
+ $object->setProfileImagePHID($value);
+ }
+
+ public function getTitle() {
+ $old = $this->getOldValue();
+ $new = $this->getNewValue();
+
+ // TODO: Some day, it would be nice to show the images.
+ if (!$old) {
+ return pht(
+ "%s set this project's image to %s.",
+ $this->renderAuthor(),
+ $this->renderNewHandle());
+ } else if (!$new) {
+ return pht(
+ "%s removed this project's image.",
+ $this->renderAuthor());
+ } else {
+ return pht(
+ "%s updated this project's image from %s to %s.",
+ $this->renderAuthor(),
+ $this->renderOldHandle(),
+ $this->renderNewHandle());
+ }
+ }
+
+ public function getTitleForFeed() {
+ $old = $this->getOldValue();
+ $new = $this->getNewValue();
+
+ // TODO: Some day, it would be nice to show the images.
+ if (!$old) {
+ return pht(
+ '%s set the image for %s to %s.',
+ $this->renderAuthor(),
+ $this->renderObject(),
+ $this->renderNewHandle());
+ } else if (!$new) {
+ return pht(
+ '%s removed the image for %s.',
+ $this->renderAuthor(),
+ $this->renderObject());
+ } else {
+ return pht(
+ '%s updated the image for %s from %s to %s.',
+ $this->renderAuthor(),
+ $this->renderObject(),
+ $this->renderOldHandle(),
+ $this->renderNewHandle());
+ }
+ }
+
+ public function getIcon() {
+ return 'fa-photo';
+ }
+
+ public function extractFilePHIDs($object, $value) {
+ if ($value) {
+ return array($value);
+ }
+ }
+
+}

File Metadata

Mime Type
text/plain
Expires
Thu, Oct 24, 1:37 PM (1 d, 14 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6746684
Default Alt Text
D17954.id43182.diff (11 KB)

Event Timeline