Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14748626
D19322.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
8 KB
Referenced Files
None
Subscribers
None
D19322.diff
View Options
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
@@ -93,11 +93,13 @@
'AlmanacNetworkEditor' => 'applications/almanac/editor/AlmanacNetworkEditor.php',
'AlmanacNetworkListController' => 'applications/almanac/controller/AlmanacNetworkListController.php',
'AlmanacNetworkNameNgrams' => 'applications/almanac/storage/AlmanacNetworkNameNgrams.php',
+ 'AlmanacNetworkNameTransaction' => 'applications/almanac/xaction/AlmanacNetworkNameTransaction.php',
'AlmanacNetworkPHIDType' => 'applications/almanac/phid/AlmanacNetworkPHIDType.php',
'AlmanacNetworkQuery' => 'applications/almanac/query/AlmanacNetworkQuery.php',
'AlmanacNetworkSearchEngine' => 'applications/almanac/query/AlmanacNetworkSearchEngine.php',
'AlmanacNetworkTransaction' => 'applications/almanac/storage/AlmanacNetworkTransaction.php',
'AlmanacNetworkTransactionQuery' => 'applications/almanac/query/AlmanacNetworkTransactionQuery.php',
+ 'AlmanacNetworkTransactionType' => 'applications/almanac/xaction/AlmanacNetworkTransactionType.php',
'AlmanacNetworkViewController' => 'applications/almanac/controller/AlmanacNetworkViewController.php',
'AlmanacPropertiesDestructionEngineExtension' => 'applications/almanac/engineextension/AlmanacPropertiesDestructionEngineExtension.php',
'AlmanacPropertiesSearchEngineAttachment' => 'applications/almanac/engineextension/AlmanacPropertiesSearchEngineAttachment.php',
@@ -5292,11 +5294,13 @@
'AlmanacNetworkEditor' => 'PhabricatorApplicationTransactionEditor',
'AlmanacNetworkListController' => 'AlmanacNetworkController',
'AlmanacNetworkNameNgrams' => 'PhabricatorSearchNgrams',
+ 'AlmanacNetworkNameTransaction' => 'AlmanacNetworkTransactionType',
'AlmanacNetworkPHIDType' => 'PhabricatorPHIDType',
'AlmanacNetworkQuery' => 'AlmanacQuery',
'AlmanacNetworkSearchEngine' => 'PhabricatorApplicationSearchEngine',
- 'AlmanacNetworkTransaction' => 'PhabricatorApplicationTransaction',
+ 'AlmanacNetworkTransaction' => 'PhabricatorModularTransaction',
'AlmanacNetworkTransactionQuery' => 'PhabricatorApplicationTransactionQuery',
+ 'AlmanacNetworkTransactionType' => 'AlmanacTransactionType',
'AlmanacNetworkViewController' => 'AlmanacNetworkController',
'AlmanacPropertiesDestructionEngineExtension' => 'PhabricatorDestructionEngineExtension',
'AlmanacPropertiesSearchEngineAttachment' => 'AlmanacSearchEngineAttachment',
diff --git a/src/applications/almanac/editor/AlmanacNetworkEditEngine.php b/src/applications/almanac/editor/AlmanacNetworkEditEngine.php
--- a/src/applications/almanac/editor/AlmanacNetworkEditEngine.php
+++ b/src/applications/almanac/editor/AlmanacNetworkEditEngine.php
@@ -81,7 +81,7 @@
->setKey('name')
->setLabel(pht('Name'))
->setDescription(pht('Name of the network.'))
- ->setTransactionType(AlmanacNetworkTransaction::TYPE_NAME)
+ ->setTransactionType(AlmanacNetworkNameTransaction::TRANSACTIONTYPE)
->setIsRequired(true)
->setValue($object->getName()),
);
diff --git a/src/applications/almanac/editor/AlmanacNetworkEditor.php b/src/applications/almanac/editor/AlmanacNetworkEditor.php
--- a/src/applications/almanac/editor/AlmanacNetworkEditor.php
+++ b/src/applications/almanac/editor/AlmanacNetworkEditor.php
@@ -15,93 +15,21 @@
return true;
}
+ public function getCreateObjectTitle($author, $object) {
+ return pht('%s created this network.', $author);
+ }
+
+ public function getCreateObjectTitleForFeed($author, $object) {
+ return pht('%s created %s.', $author, $object);
+ }
+
public function getTransactionTypes() {
$types = parent::getTransactionTypes();
- $types[] = AlmanacNetworkTransaction::TYPE_NAME;
$types[] = PhabricatorTransactions::TYPE_VIEW_POLICY;
$types[] = PhabricatorTransactions::TYPE_EDIT_POLICY;
return $types;
}
- protected function getCustomTransactionOldValue(
- PhabricatorLiskDAO $object,
- PhabricatorApplicationTransaction $xaction) {
- switch ($xaction->getTransactionType()) {
- case AlmanacNetworkTransaction::TYPE_NAME:
- return $object->getName();
- }
-
- return parent::getCustomTransactionOldValue($object, $xaction);
- }
-
- protected function getCustomTransactionNewValue(
- PhabricatorLiskDAO $object,
- PhabricatorApplicationTransaction $xaction) {
-
- switch ($xaction->getTransactionType()) {
- case AlmanacNetworkTransaction::TYPE_NAME:
- return $xaction->getNewValue();
- }
-
- return parent::getCustomTransactionNewValue($object, $xaction);
- }
-
- protected function applyCustomInternalTransaction(
- PhabricatorLiskDAO $object,
- PhabricatorApplicationTransaction $xaction) {
-
- switch ($xaction->getTransactionType()) {
- case AlmanacNetworkTransaction::TYPE_NAME:
- $object->setName($xaction->getNewValue());
- return;
- }
-
- return parent::applyCustomInternalTransaction($object, $xaction);
- }
-
- protected function applyCustomExternalTransaction(
- PhabricatorLiskDAO $object,
- PhabricatorApplicationTransaction $xaction) {
-
- switch ($xaction->getTransactionType()) {
- case AlmanacNetworkTransaction::TYPE_NAME:
- return;
- }
-
- return parent::applyCustomExternalTransaction($object, $xaction);
- }
-
- protected function validateTransaction(
- PhabricatorLiskDAO $object,
- $type,
- array $xactions) {
-
- $errors = parent::validateTransaction($object, $type, $xactions);
-
- switch ($type) {
- case AlmanacNetworkTransaction::TYPE_NAME:
- $missing = $this->validateIsEmptyTextField(
- $object->getName(),
- $xactions);
-
- if ($missing) {
- $error = new PhabricatorApplicationTransactionValidationError(
- $type,
- pht('Required'),
- pht('Network name is required.'),
- nonempty(last($xactions), null));
-
- $error->setIsMissingFieldError(true);
- $errors[] = $error;
- }
- break;
- }
-
- return $errors;
- }
-
-
-
}
diff --git a/src/applications/almanac/storage/AlmanacNetworkTransaction.php b/src/applications/almanac/storage/AlmanacNetworkTransaction.php
--- a/src/applications/almanac/storage/AlmanacNetworkTransaction.php
+++ b/src/applications/almanac/storage/AlmanacNetworkTransaction.php
@@ -1,9 +1,7 @@
<?php
final class AlmanacNetworkTransaction
- extends PhabricatorApplicationTransaction {
-
- const TYPE_NAME = 'almanac:network:name';
+ extends PhabricatorModularTransaction {
public function getApplicationName() {
return 'almanac';
@@ -17,26 +15,8 @@
return null;
}
- public function getTitle() {
- $author_phid = $this->getAuthorPHID();
-
- $old = $this->getOldValue();
- $new = $this->getNewValue();
-
- switch ($this->getTransactionType()) {
- case PhabricatorTransactions::TYPE_CREATE:
- return pht(
- '%s created this network.',
- $this->renderHandleLink($author_phid));
- case self::TYPE_NAME:
- return pht(
- '%s renamed this network from "%s" to "%s".',
- $this->renderHandleLink($author_phid),
- $old,
- $new);
- }
-
- return parent::getTitle();
+ public function getBaseTransactionClass() {
+ return 'AlmanacNetworkTransactionType';
}
}
diff --git a/src/applications/almanac/xaction/AlmanacNetworkNameTransaction.php b/src/applications/almanac/xaction/AlmanacNetworkNameTransaction.php
new file mode 100644
--- /dev/null
+++ b/src/applications/almanac/xaction/AlmanacNetworkNameTransaction.php
@@ -0,0 +1,44 @@
+<?php
+
+final class AlmanacNetworkNameTransaction
+ extends AlmanacNetworkTransactionType {
+
+ const TRANSACTIONTYPE = 'almanac:network:name';
+
+ public function generateOldValue($object) {
+ return $object->getName();
+ }
+
+ public function applyInternalEffects($object, $value) {
+ $object->setName($value);
+ }
+
+ public function getTitle() {
+ return pht(
+ '%s renamed this network from %s to %s.',
+ $this->renderAuthor(),
+ $this->renderOldValue(),
+ $this->renderNewValue());
+ }
+
+ public function getTitleForFeed() {
+ return pht(
+ '%s renamed %s from %s to %s.',
+ $this->renderAuthor(),
+ $this->renderObject(),
+ $this->renderOldValue(),
+ $this->renderNewValue());
+ }
+
+ public function validateTransactions($object, array $xactions) {
+ $errors = array();
+
+ if ($this->isEmptyTextTransaction($object->getName(), $xactions)) {
+ $errors[] = $this->newRequiredError(
+ pht('Network name is required.'));
+ }
+
+ return $errors;
+ }
+
+}
diff --git a/src/applications/almanac/xaction/AlmanacNetworkTransactionType.php b/src/applications/almanac/xaction/AlmanacNetworkTransactionType.php
new file mode 100644
--- /dev/null
+++ b/src/applications/almanac/xaction/AlmanacNetworkTransactionType.php
@@ -0,0 +1,4 @@
+<?php
+
+abstract class AlmanacNetworkTransactionType
+ extends AlmanacTransactionType {}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Jan 22, 11:00 AM (4 h, 43 s)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7030955
Default Alt Text
D19322.diff (8 KB)
Attached To
Mode
D19322: Modularize Almanac Network transactions
Attached
Detach File
Event Timeline
Log In to Comment