Page MenuHomePhabricator

D17988.id43260.diff
No OneTemporary

D17988.id43260.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
@@ -4627,6 +4627,7 @@
'PhrictionDocumentHeraldAdapter' => 'applications/phriction/herald/PhrictionDocumentHeraldAdapter.php',
'PhrictionDocumentHeraldField' => 'applications/phriction/herald/PhrictionDocumentHeraldField.php',
'PhrictionDocumentHeraldFieldGroup' => 'applications/phriction/herald/PhrictionDocumentHeraldFieldGroup.php',
+ 'PhrictionDocumentMoveAwayTransaction' => 'applications/phriction/xaction/PhrictionDocumentMoveAwayTransaction.php',
'PhrictionDocumentMoveToTransaction' => 'applications/phriction/xaction/PhrictionDocumentMoveToTransaction.php',
'PhrictionDocumentPHIDType' => 'applications/phriction/phid/PhrictionDocumentPHIDType.php',
'PhrictionDocumentPathHeraldField' => 'applications/phriction/herald/PhrictionDocumentPathHeraldField.php',
@@ -10277,6 +10278,7 @@
'PhrictionDocumentHeraldAdapter' => 'HeraldAdapter',
'PhrictionDocumentHeraldField' => 'HeraldField',
'PhrictionDocumentHeraldFieldGroup' => 'HeraldFieldGroup',
+ 'PhrictionDocumentMoveAwayTransaction' => 'PhrictionDocumentTransactionType',
'PhrictionDocumentMoveToTransaction' => 'PhrictionDocumentTransactionType',
'PhrictionDocumentPHIDType' => 'PhabricatorPHIDType',
'PhrictionDocumentPathHeraldField' => 'PhrictionDocumentHeraldField',
diff --git a/src/applications/phriction/editor/PhrictionTransactionEditor.php b/src/applications/phriction/editor/PhrictionTransactionEditor.php
--- a/src/applications/phriction/editor/PhrictionTransactionEditor.php
+++ b/src/applications/phriction/editor/PhrictionTransactionEditor.php
@@ -87,7 +87,6 @@
$types[] = PhrictionTransaction::TYPE_CONTENT;
$types[] = PhrictionTransaction::TYPE_DELETE;
- $types[] = PhrictionTransaction::TYPE_MOVE_AWAY;
$types[] = PhabricatorTransactions::TYPE_EDGE;
$types[] = PhabricatorTransactions::TYPE_COMMENT;
@@ -108,7 +107,6 @@
}
return $this->getOldContent()->getContent();
case PhrictionTransaction::TYPE_DELETE:
- case PhrictionTransaction::TYPE_MOVE_AWAY:
return null;
}
}
@@ -121,15 +119,6 @@
case PhrictionTransaction::TYPE_CONTENT:
case PhrictionTransaction::TYPE_DELETE:
return $xaction->getNewValue();
- case PhrictionTransaction::TYPE_MOVE_AWAY:
- $document = $xaction->getNewValue();
- $dict = array(
- 'id' => $document->getID(),
- 'phid' => $document->getPHID(),
- 'content' => $document->getContent()->getContent(),
- 'title' => $document->getContent()->getTitle(),
- );
- return $dict;
}
}
@@ -143,7 +132,7 @@
case PhrictionTransaction::TYPE_CONTENT:
case PhrictionTransaction::TYPE_DELETE:
case PhrictionDocumentMoveToTransaction::TRANSACTIONTYPE:
- case PhrictionTransaction::TYPE_MOVE_AWAY:
+ case PhrictionDocumentMoveAwayTransaction::TRANSACTIONTYPE:
return true;
}
}
@@ -166,9 +155,6 @@
case PhrictionTransaction::TYPE_CONTENT:
$object->setStatus(PhrictionDocumentStatus::STATUS_EXISTS);
return;
- case PhrictionTransaction::TYPE_MOVE_AWAY:
- $object->setStatus(PhrictionDocumentStatus::STATUS_MOVED);
- return;
case PhrictionTransaction::TYPE_DELETE:
$object->setStatus(PhrictionDocumentStatus::STATUS_DELETED);
return;
@@ -223,13 +209,6 @@
$this->getNewContent()->setChangeType(
PhrictionChangeType::CHANGE_DELETE);
break;
- case PhrictionTransaction::TYPE_MOVE_AWAY:
- $dict = $xaction->getNewValue();
- $this->getNewContent()->setContent('');
- $this->getNewContent()->setChangeType(
- PhrictionChangeType::CHANGE_MOVE_AWAY);
- $this->getNewContent()->setChangeRef($dict['id']);
- break;
default:
break;
}
@@ -244,9 +223,9 @@
switch ($xaction->getTransactionType()) {
case PhrictionDocumentTitleTransaction::TRANSACTIONTYPE:
case PhrictionDocumentMoveToTransaction::TRANSACTIONTYPE:
+ case PhrictionDocumentMoveAwayTransaction::TRANSACTIONTYPE:
case PhrictionTransaction::TYPE_CONTENT:
case PhrictionTransaction::TYPE_DELETE:
- case PhrictionTransaction::TYPE_MOVE_AWAY:
$save_content = true;
break;
default:
@@ -313,7 +292,8 @@
if ($this->moveAwayDocument !== null) {
$move_away_xactions = array();
$move_away_xactions[] = id(new PhrictionTransaction())
- ->setTransactionType(PhrictionTransaction::TYPE_MOVE_AWAY)
+ ->setTransactionType(
+ PhrictionDocumentMoveAwayTransaction::TRANSACTIONTYPE)
->setNewValue($object);
$sub_editor = id(new PhrictionTransactionEditor())
->setActor($this->getActor())
diff --git a/src/applications/phriction/storage/PhrictionTransaction.php b/src/applications/phriction/storage/PhrictionTransaction.php
--- a/src/applications/phriction/storage/PhrictionTransaction.php
+++ b/src/applications/phriction/storage/PhrictionTransaction.php
@@ -5,7 +5,6 @@
const TYPE_CONTENT = 'content';
const TYPE_DELETE = 'delete';
- const TYPE_MOVE_AWAY = 'move-away';
const MAILTAG_TITLE = 'phriction-title';
const MAILTAG_CONTENT = 'phriction-content';
@@ -34,7 +33,7 @@
$new = $this->getNewValue();
switch ($this->getTransactionType()) {
case PhrictionDocumentMoveToTransaction::TRANSACTIONTYPE:
- case self::TYPE_MOVE_AWAY:
+ case PhrictionDocumentMoveAwayTransaction::TRANSACTIONTYPE:
$phids[] = $new['phid'];
break;
case PhrictionDocumentTitleTransaction::TRANSACTIONTYPE:
@@ -76,7 +75,7 @@
public function shouldHideForMail(array $xactions) {
switch ($this->getTransactionType()) {
case PhrictionDocumentMoveToTransaction::TRANSACTIONTYPE:
- case self::TYPE_MOVE_AWAY:
+ case PhrictionDocumentMoveAwayTransaction::TRANSACTIONTYPE:
return true;
case PhrictionDocumentTitleTransaction::TRANSACTIONTYPE:
return $this->getMetadataValue('stub:create:phid', false);
@@ -87,7 +86,7 @@
public function shouldHideForFeed() {
switch ($this->getTransactionType()) {
case PhrictionDocumentMoveToTransaction::TRANSACTIONTYPE:
- case self::TYPE_MOVE_AWAY:
+ case PhrictionDocumentMoveAwayTransaction::TRANSACTIONTYPE:
return true;
case PhrictionDocumentTitleTransaction::TRANSACTIONTYPE:
return $this->getMetadataValue('stub:create:phid', false);
@@ -101,8 +100,6 @@
return 1.3;
case self::TYPE_DELETE:
return 1.5;
- case self::TYPE_MOVE_AWAY:
- return 1.0;
}
return parent::getActionStrength();
@@ -117,8 +114,6 @@
return pht('Edited');
case self::TYPE_DELETE:
return pht('Deleted');
- case self::TYPE_MOVE_AWAY:
- return pht('Moved Away');
}
return parent::getActionName();
@@ -133,8 +128,6 @@
return 'fa-pencil';
case self::TYPE_DELETE:
return 'fa-times';
- case self::TYPE_MOVE_AWAY:
- return 'fa-arrows';
}
return parent::getIcon();
@@ -158,12 +151,6 @@
'%s deleted this document.',
$this->renderHandleLink($author_phid));
- case self::TYPE_MOVE_AWAY:
- return pht(
- '%s moved this document to %s',
- $this->renderHandleLink($author_phid),
- $this->renderHandleLink($new['phid']));
-
}
return parent::getTitle();
diff --git a/src/applications/phriction/xaction/PhrictionDocumentMoveAwayTransaction.php b/src/applications/phriction/xaction/PhrictionDocumentMoveAwayTransaction.php
new file mode 100644
--- /dev/null
+++ b/src/applications/phriction/xaction/PhrictionDocumentMoveAwayTransaction.php
@@ -0,0 +1,68 @@
+<?php
+
+final class PhrictionDocumentMoveAwayTransaction
+ extends PhrictionDocumentTransactionType {
+
+ const TRANSACTIONTYPE = 'move-away';
+
+ public function generateOldValue($object) {
+ return null;
+ }
+
+ public function generateNewValue($object, $value) {
+ $document = $value;
+ $dict = array(
+ 'id' => $document->getID(),
+ 'phid' => $document->getPHID(),
+ 'content' => $document->getContent()->getContent(),
+ 'title' => $document->getContent()->getTitle(),
+ );
+ return $dict;
+ }
+
+ public function applyInternalEffects($object, $value) {
+ $object->setStatus(PhrictionDocumentStatus::STATUS_MOVED);
+ }
+
+ public function applyExternalEffects($object, $value) {
+ $dict = $value;
+ $this->getEditor()->getNewContent()->setContent('');
+ $this->getEditor()->getNewContent()->setChangeType(
+ PhrictionChangeType::CHANGE_MOVE_AWAY);
+ $this->getEditor()->getNewContent()->setChangeRef($dict['id']);
+ }
+
+ public function getActionStrength() {
+ return 1.0;
+ }
+
+ public function getActionName() {
+ return pht('Moved Away');
+ }
+
+ public function getTitle() {
+ $old = $this->getOldValue();
+ $new = $this->getNewValue();
+
+ return pht(
+ '%s moved this document to %s',
+ $this->renderAuthor(),
+ $this->renderHandleLink($new['phid']));
+ }
+
+ public function getTitleForFeed() {
+ $old = $this->getOldValue();
+ $new = $this->getNewValue();
+
+ return pht(
+ '%s moved %s to %s',
+ $this->renderAuthor(),
+ $this->renderObject(),
+ $this->renderHandleLink($new['phid']));
+ }
+
+ public function getIcon() {
+ return 'fa-arrows';
+ }
+
+}

File Metadata

Mime Type
text/plain
Expires
Fri, Mar 28, 6:06 AM (2 w, 6 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7725166
Default Alt Text
D17988.id43260.diff (9 KB)

Event Timeline