Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F18103662
D17865.id42963.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
9 KB
Referenced Files
None
Subscribers
None
D17865.id42963.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
@@ -4388,6 +4388,7 @@
'PholioMockSearchEngine' => 'applications/pholio/query/PholioMockSearchEngine.php',
'PholioMockThumbGridView' => 'applications/pholio/view/PholioMockThumbGridView.php',
'PholioMockViewController' => 'applications/pholio/controller/PholioMockViewController.php',
+ 'PholioNameTransaction' => 'applications/pholio/xaction/PholioNameTransaction.php',
'PholioRemarkupRule' => 'applications/pholio/remarkup/PholioRemarkupRule.php',
'PholioReplyHandler' => 'applications/pholio/mail/PholioReplyHandler.php',
'PholioSchemaSpec' => 'applications/pholio/storage/PholioSchemaSpec.php',
@@ -9940,6 +9941,7 @@
'PholioMockSearchEngine' => 'PhabricatorApplicationSearchEngine',
'PholioMockThumbGridView' => 'AphrontView',
'PholioMockViewController' => 'PholioController',
+ 'PholioNameTransaction' => 'PholioTransactionType',
'PholioRemarkupRule' => 'PhabricatorObjectRemarkupRule',
'PholioReplyHandler' => 'PhabricatorApplicationTransactionReplyHandler',
'PholioSchemaSpec' => 'PhabricatorConfigSchemaSpec',
diff --git a/src/applications/pholio/controller/PholioMockEditController.php b/src/applications/pholio/controller/PholioMockEditController.php
--- a/src/applications/pholio/controller/PholioMockEditController.php
+++ b/src/applications/pholio/controller/PholioMockEditController.php
@@ -65,7 +65,7 @@
if ($request->isFormPost()) {
$xactions = array();
- $type_name = PholioTransaction::TYPE_NAME;
+ $type_name = PholioNameTransaction::TRANSACTIONTYPE;
$type_desc = PholioDescriptionTransaction::TRANSACTIONTYPE;
$type_view = PhabricatorTransactions::TYPE_VIEW_POLICY;
$type_edit = PhabricatorTransactions::TYPE_EDIT_POLICY;
@@ -88,11 +88,6 @@
$mock_xactions[$type_cc] = array('=' => $v_cc);
$mock_xactions[$type_space] = $v_space;
- if (!strlen($request->getStr('name'))) {
- $e_name = pht('Required');
- $errors[] = pht('You must give the mock a name.');
- }
-
$file_phids = $request->getArr('file_phids');
if ($file_phids) {
$files = id(new PhabricatorFileQuery())
diff --git a/src/applications/pholio/editor/PholioMockEditor.php b/src/applications/pholio/editor/PholioMockEditor.php
--- a/src/applications/pholio/editor/PholioMockEditor.php
+++ b/src/applications/pholio/editor/PholioMockEditor.php
@@ -29,7 +29,6 @@
$types[] = PhabricatorTransactions::TYPE_VIEW_POLICY;
$types[] = PhabricatorTransactions::TYPE_EDIT_POLICY;
- $types[] = PholioTransaction::TYPE_NAME;
$types[] = PholioTransaction::TYPE_STATUS;
$types[] = PholioTransaction::TYPE_INLINE;
@@ -47,8 +46,6 @@
PhabricatorApplicationTransaction $xaction) {
switch ($xaction->getTransactionType()) {
- case PholioTransaction::TYPE_NAME:
- return $object->getName();
case PholioTransaction::TYPE_STATUS:
return $object->getStatus();
case PholioTransaction::TYPE_IMAGE_FILE:
@@ -92,7 +89,6 @@
PhabricatorApplicationTransaction $xaction) {
switch ($xaction->getTransactionType()) {
- case PholioTransaction::TYPE_NAME:
case PholioTransaction::TYPE_STATUS:
case PholioTransaction::TYPE_IMAGE_NAME:
case PholioTransaction::TYPE_IMAGE_DESCRIPTION:
@@ -205,12 +201,6 @@
PhabricatorApplicationTransaction $xaction) {
switch ($xaction->getTransactionType()) {
- case PholioTransaction::TYPE_NAME:
- $object->setName($xaction->getNewValue());
- if ($object->getOriginalName() === null) {
- $object->setOriginalName($xaction->getNewValue());
- }
- break;
case PholioTransaction::TYPE_STATUS:
$object->setStatus($xaction->getNewValue());
break;
@@ -303,7 +293,6 @@
$type = $u->getTransactionType();
switch ($type) {
- case PholioTransaction::TYPE_NAME:
case PholioTransaction::TYPE_STATUS:
return $v;
case PholioTransaction::TYPE_IMAGE_REPLACE:
diff --git a/src/applications/pholio/lipsum/PhabricatorPholioMockTestDataGenerator.php b/src/applications/pholio/lipsum/PhabricatorPholioMockTestDataGenerator.php
--- a/src/applications/pholio/lipsum/PhabricatorPholioMockTestDataGenerator.php
+++ b/src/applications/pholio/lipsum/PhabricatorPholioMockTestDataGenerator.php
@@ -22,7 +22,7 @@
// Accumulate Transactions
$changes = array();
- $changes[PholioTransaction::TYPE_NAME] =
+ $changes[PholioNameTransaction::TRANSACTIONTYPE] =
$this->generateTitle();
$changes[PholioDescriptionTransaction::TRANSACTIONTYPE] =
$this->generateDescription();
diff --git a/src/applications/pholio/storage/PholioTransaction.php b/src/applications/pholio/storage/PholioTransaction.php
--- a/src/applications/pholio/storage/PholioTransaction.php
+++ b/src/applications/pholio/storage/PholioTransaction.php
@@ -3,7 +3,6 @@
final class PholioTransaction extends PhabricatorModularTransaction {
// Edits to the high level mock
- const TYPE_NAME = 'name';
const TYPE_STATUS = 'status';
// Edits to images within the mock
@@ -89,7 +88,6 @@
switch ($this->getTransactionType()) {
case self::TYPE_INLINE:
return 'fa-comment';
- case self::TYPE_NAME:
case self::TYPE_STATUS:
if ($new == PholioMock::STATUS_CLOSED) {
return 'fa-ban';
@@ -118,7 +116,7 @@
case self::TYPE_STATUS:
$tags[] = self::MAILTAG_STATUS;
break;
- case self::TYPE_NAME:
+ case PholioNameTransaction::TRANSACTIONTYPE:
case PholioDescriptionTransaction::TRANSACTIONTYPE:
case self::TYPE_IMAGE_NAME:
case self::TYPE_IMAGE_DESCRIPTION:
@@ -142,20 +140,6 @@
$type = $this->getTransactionType();
switch ($type) {
- case self::TYPE_NAME:
- if ($old === null) {
- return pht(
- '%s created "%s".',
- $this->renderHandleLink($author_phid),
- $new);
- } else {
- return pht(
- '%s renamed this mock from "%s" to "%s".',
- $this->renderHandleLink($author_phid),
- $old,
- $new);
- }
- break;
case self::TYPE_STATUS:
if ($new == PholioMock::STATUS_CLOSED) {
return pht(
@@ -248,21 +232,6 @@
$type = $this->getTransactionType();
switch ($type) {
- case self::TYPE_NAME:
- if ($old === null) {
- return pht(
- '%s created %s.',
- $this->renderHandleLink($author_phid),
- $this->renderHandleLink($object_phid));
- } else {
- return pht(
- '%s renamed %s from "%s" to "%s".',
- $this->renderHandleLink($author_phid),
- $this->renderHandleLink($object_phid),
- $old,
- $new);
- }
- break;
case self::TYPE_STATUS:
if ($new == PholioMock::STATUS_CLOSED) {
return pht(
@@ -312,23 +281,6 @@
return parent::getTitleForFeed();
}
- public function getRemarkupBodyForFeed(PhabricatorFeedStory $story) {
- $text = null;
- switch ($this->getTransactionType()) {
- case self::TYPE_NAME:
- if ($this->getOldValue() === null) {
- $mock = $story->getPrimaryObject();
- $text = $mock->getDescription();
- }
- break;
- case self::TYPE_INLINE:
- $text = $this->getComment()->getContent();
- break;
- }
-
- return $text;
- }
-
public function getColor() {
$old = $this->getOldValue();
$new = $this->getNewValue();
@@ -340,10 +292,6 @@
} else {
return PhabricatorTransactions::COLOR_GREEN;
}
- case self::TYPE_NAME:
- if ($old === null) {
- return PhabricatorTransactions::COLOR_GREEN;
- }
case self::TYPE_IMAGE_REPLACE:
return PhabricatorTransactions::COLOR_YELLOW;
case self::TYPE_IMAGE_FILE:
diff --git a/src/applications/pholio/xaction/PholioNameTransaction.php b/src/applications/pholio/xaction/PholioNameTransaction.php
new file mode 100644
--- /dev/null
+++ b/src/applications/pholio/xaction/PholioNameTransaction.php
@@ -0,0 +1,76 @@
+<?php
+
+final class PholioNameTransaction
+ extends PholioTransactionType {
+
+ const TRANSACTIONTYPE = 'name';
+
+ public function generateOldValue($object) {
+ return $object->getName();
+ }
+
+ public function applyInternalEffects($object, $value) {
+ $object->setName($value);
+ if ($object->getOriginalName() === null) {
+ $object->setOriginalName($this->getNewValue());
+ }
+ }
+
+ public function getTitle() {
+ $old = $this->getOldValue();
+ $new = $this->getNewValue();
+
+ if ($old === null) {
+ return pht(
+ '%s created "%s".',
+ $this->renderAuthor(),
+ $this->renderValue($new));
+ } else {
+ return pht(
+ '%s renamed this mock from %s to %s.',
+ $this->renderAuthor(),
+ $this->renderValue($old),
+ $this->renderValue($new));
+ }
+ }
+
+ public function getTitleForFeed() {
+ $old = $this->getOldValue();
+ $new = $this->getNewValue();
+
+ if ($old === null) {
+ return pht(
+ '%s created %s.',
+ $this->renderAuthor(),
+ $this->renderObject());
+ } else {
+ return pht(
+ '%s renamed %s from %s to %s.',
+ $this->renderAuthor(),
+ $this->renderObject(),
+ $this->renderValue($old),
+ $this->renderValue($new));
+ }
+ }
+
+ public function getColor() {
+ $old = $this->getOldValue();
+
+ if ($old === null) {
+ return PhabricatorTransactions::COLOR_GREEN;
+ }
+
+ return parent::getColor();
+ }
+
+ public function validateTransactions($object, array $xactions) {
+ $errors = array();
+
+ if ($this->isEmptyTextTransaction($object->getName(), $xactions)) {
+ $errors[] = $this->newRequiredError(pht('Mocks must have a name.'));
+ }
+
+ return $errors;
+ }
+
+}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Aug 11 2025, 7:13 AM (21 w, 4 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
9113966
Default Alt Text
D17865.id42963.diff (9 KB)
Attached To
Mode
D17865: Migate more of Pholio to Modular Transaction
Attached
Detach File
Event Timeline
Log In to Comment