Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F18745805
D19334.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
40 KB
Referenced Files
None
Subscribers
None
D19334.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
@@ -12,6 +12,7 @@
'AlamancServiceEditConduitAPIMethod' => 'applications/almanac/conduit/AlamancServiceEditConduitAPIMethod.php',
'AlmanacAddress' => 'applications/almanac/util/AlmanacAddress.php',
'AlmanacBinding' => 'applications/almanac/storage/AlmanacBinding.php',
+ 'AlmanacBindingDeletePropertyTransaction' => 'applications/almanac/xaction/AlmanacBindingDeletePropertyTransaction.php',
'AlmanacBindingDisableController' => 'applications/almanac/controller/AlmanacBindingDisableController.php',
'AlmanacBindingDisableTransaction' => 'applications/almanac/xaction/AlmanacBindingDisableTransaction.php',
'AlmanacBindingEditController' => 'applications/almanac/controller/AlmanacBindingEditController.php',
@@ -20,6 +21,7 @@
'AlmanacBindingPHIDType' => 'applications/almanac/phid/AlmanacBindingPHIDType.php',
'AlmanacBindingPropertyEditEngine' => 'applications/almanac/editor/AlmanacBindingPropertyEditEngine.php',
'AlmanacBindingQuery' => 'applications/almanac/query/AlmanacBindingQuery.php',
+ 'AlmanacBindingSetPropertyTransaction' => 'applications/almanac/xaction/AlmanacBindingSetPropertyTransaction.php',
'AlmanacBindingTableView' => 'applications/almanac/view/AlmanacBindingTableView.php',
'AlmanacBindingTransaction' => 'applications/almanac/storage/AlmanacBindingTransaction.php',
'AlmanacBindingTransactionQuery' => 'applications/almanac/query/AlmanacBindingTransactionQuery.php',
@@ -40,6 +42,7 @@
'AlmanacDAO' => 'applications/almanac/storage/AlmanacDAO.php',
'AlmanacDevice' => 'applications/almanac/storage/AlmanacDevice.php',
'AlmanacDeviceController' => 'applications/almanac/controller/AlmanacDeviceController.php',
+ 'AlmanacDeviceDeletePropertyTransaction' => 'applications/almanac/xaction/AlmanacDeviceDeletePropertyTransaction.php',
'AlmanacDeviceEditConduitAPIMethod' => 'applications/almanac/conduit/AlmanacDeviceEditConduitAPIMethod.php',
'AlmanacDeviceEditController' => 'applications/almanac/controller/AlmanacDeviceEditController.php',
'AlmanacDeviceEditEngine' => 'applications/almanac/editor/AlmanacDeviceEditEngine.php',
@@ -52,6 +55,7 @@
'AlmanacDeviceQuery' => 'applications/almanac/query/AlmanacDeviceQuery.php',
'AlmanacDeviceSearchConduitAPIMethod' => 'applications/almanac/conduit/AlmanacDeviceSearchConduitAPIMethod.php',
'AlmanacDeviceSearchEngine' => 'applications/almanac/query/AlmanacDeviceSearchEngine.php',
+ 'AlmanacDeviceSetPropertyTransaction' => 'applications/almanac/xaction/AlmanacDeviceSetPropertyTransaction.php',
'AlmanacDeviceTransaction' => 'applications/almanac/storage/AlmanacDeviceTransaction.php',
'AlmanacDeviceTransactionQuery' => 'applications/almanac/query/AlmanacDeviceTransactionQuery.php',
'AlmanacDeviceTransactionType' => 'applications/almanac/xaction/AlmanacDeviceTransactionType.php',
@@ -80,6 +84,7 @@
'AlmanacManagementTrustKeyWorkflow' => 'applications/almanac/management/AlmanacManagementTrustKeyWorkflow.php',
'AlmanacManagementUntrustKeyWorkflow' => 'applications/almanac/management/AlmanacManagementUntrustKeyWorkflow.php',
'AlmanacManagementWorkflow' => 'applications/almanac/management/AlmanacManagementWorkflow.php',
+ 'AlmanacModularTransaction' => 'applications/almanac/storage/AlmanacModularTransaction.php',
'AlmanacNames' => 'applications/almanac/util/AlmanacNames.php',
'AlmanacNamesTestCase' => 'applications/almanac/util/__tests__/AlmanacNamesTestCase.php',
'AlmanacNamespace' => 'applications/almanac/storage/AlmanacNamespace.php',
@@ -127,6 +132,7 @@
'AlmanacService' => 'applications/almanac/storage/AlmanacService.php',
'AlmanacServiceController' => 'applications/almanac/controller/AlmanacServiceController.php',
'AlmanacServiceDatasource' => 'applications/almanac/typeahead/AlmanacServiceDatasource.php',
+ 'AlmanacServiceDeletePropertyTransaction' => 'applications/almanac/xaction/AlmanacServiceDeletePropertyTransaction.php',
'AlmanacServiceEditController' => 'applications/almanac/controller/AlmanacServiceEditController.php',
'AlmanacServiceEditEngine' => 'applications/almanac/editor/AlmanacServiceEditEngine.php',
'AlmanacServiceEditor' => 'applications/almanac/editor/AlmanacServiceEditor.php',
@@ -138,6 +144,7 @@
'AlmanacServiceQuery' => 'applications/almanac/query/AlmanacServiceQuery.php',
'AlmanacServiceSearchConduitAPIMethod' => 'applications/almanac/conduit/AlmanacServiceSearchConduitAPIMethod.php',
'AlmanacServiceSearchEngine' => 'applications/almanac/query/AlmanacServiceSearchEngine.php',
+ 'AlmanacServiceSetPropertyTransaction' => 'applications/almanac/xaction/AlmanacServiceSetPropertyTransaction.php',
'AlmanacServiceTransaction' => 'applications/almanac/storage/AlmanacServiceTransaction.php',
'AlmanacServiceTransactionQuery' => 'applications/almanac/query/AlmanacServiceTransactionQuery.php',
'AlmanacServiceTransactionType' => 'applications/almanac/xaction/AlmanacServiceTransactionType.php',
@@ -146,7 +153,6 @@
'AlmanacServiceTypeTestCase' => 'applications/almanac/servicetype/__tests__/AlmanacServiceTypeTestCase.php',
'AlmanacServiceTypeTransaction' => 'applications/almanac/xaction/AlmanacServiceTypeTransaction.php',
'AlmanacServiceViewController' => 'applications/almanac/controller/AlmanacServiceViewController.php',
- 'AlmanacTransaction' => 'applications/almanac/storage/AlmanacTransaction.php',
'AlmanacTransactionType' => 'applications/almanac/xaction/AlmanacTransactionType.php',
'AphlictDropdownDataQuery' => 'applications/aphlict/query/AphlictDropdownDataQuery.php',
'Aphront304Response' => 'aphront/response/Aphront304Response.php',
@@ -5194,6 +5200,7 @@
'PhabricatorDestructibleInterface',
'PhabricatorExtendedPolicyInterface',
),
+ 'AlmanacBindingDeletePropertyTransaction' => 'AlmanacBindingTransactionType',
'AlmanacBindingDisableController' => 'AlmanacServiceController',
'AlmanacBindingDisableTransaction' => 'AlmanacBindingTransactionType',
'AlmanacBindingEditController' => 'AlmanacServiceController',
@@ -5202,8 +5209,9 @@
'AlmanacBindingPHIDType' => 'PhabricatorPHIDType',
'AlmanacBindingPropertyEditEngine' => 'AlmanacPropertyEditEngine',
'AlmanacBindingQuery' => 'AlmanacQuery',
+ 'AlmanacBindingSetPropertyTransaction' => 'AlmanacBindingTransactionType',
'AlmanacBindingTableView' => 'AphrontView',
- 'AlmanacBindingTransaction' => 'PhabricatorModularTransaction',
+ 'AlmanacBindingTransaction' => 'AlmanacModularTransaction',
'AlmanacBindingTransactionQuery' => 'PhabricatorApplicationTransactionQuery',
'AlmanacBindingTransactionType' => 'AlmanacTransactionType',
'AlmanacBindingViewController' => 'AlmanacServiceController',
@@ -5233,6 +5241,7 @@
'PhabricatorExtendedPolicyInterface',
),
'AlmanacDeviceController' => 'AlmanacController',
+ 'AlmanacDeviceDeletePropertyTransaction' => 'AlmanacDeviceTransactionType',
'AlmanacDeviceEditConduitAPIMethod' => 'PhabricatorEditEngineAPIMethod',
'AlmanacDeviceEditController' => 'AlmanacDeviceController',
'AlmanacDeviceEditEngine' => 'PhabricatorEditEngine',
@@ -5245,7 +5254,8 @@
'AlmanacDeviceQuery' => 'AlmanacQuery',
'AlmanacDeviceSearchConduitAPIMethod' => 'PhabricatorSearchEngineAPIMethod',
'AlmanacDeviceSearchEngine' => 'PhabricatorApplicationSearchEngine',
- 'AlmanacDeviceTransaction' => 'PhabricatorModularTransaction',
+ 'AlmanacDeviceSetPropertyTransaction' => 'AlmanacDeviceTransactionType',
+ 'AlmanacDeviceTransaction' => 'AlmanacModularTransaction',
'AlmanacDeviceTransactionQuery' => 'PhabricatorApplicationTransactionQuery',
'AlmanacDeviceTransactionType' => 'AlmanacTransactionType',
'AlmanacDeviceViewController' => 'AlmanacDeviceController',
@@ -5265,13 +5275,13 @@
'AlmanacInterfaceDeviceTransaction' => 'AlmanacInterfaceTransactionType',
'AlmanacInterfaceEditController' => 'AlmanacDeviceController',
'AlmanacInterfaceEditEngine' => 'PhabricatorEditEngine',
- 'AlmanacInterfaceEditor' => 'PhabricatorApplicationTransactionEditor',
+ 'AlmanacInterfaceEditor' => 'AlmanacEditor',
'AlmanacInterfaceNetworkTransaction' => 'AlmanacInterfaceTransactionType',
'AlmanacInterfacePHIDType' => 'PhabricatorPHIDType',
'AlmanacInterfacePortTransaction' => 'AlmanacInterfaceTransactionType',
'AlmanacInterfaceQuery' => 'AlmanacQuery',
'AlmanacInterfaceTableView' => 'AphrontView',
- 'AlmanacInterfaceTransaction' => 'PhabricatorModularTransaction',
+ 'AlmanacInterfaceTransaction' => 'AlmanacModularTransaction',
'AlmanacInterfaceTransactionType' => 'AlmanacTransactionType',
'AlmanacKeys' => 'Phobject',
'AlmanacManageClusterServicesCapability' => 'PhabricatorPolicyCapability',
@@ -5279,6 +5289,7 @@
'AlmanacManagementTrustKeyWorkflow' => 'AlmanacManagementWorkflow',
'AlmanacManagementUntrustKeyWorkflow' => 'AlmanacManagementWorkflow',
'AlmanacManagementWorkflow' => 'PhabricatorManagementWorkflow',
+ 'AlmanacModularTransaction' => 'PhabricatorModularTransaction',
'AlmanacNames' => 'Phobject',
'AlmanacNamesTestCase' => 'PhabricatorTestCase',
'AlmanacNamespace' => array(
@@ -5293,14 +5304,14 @@
'AlmanacNamespaceController' => 'AlmanacController',
'AlmanacNamespaceEditController' => 'AlmanacNamespaceController',
'AlmanacNamespaceEditEngine' => 'PhabricatorEditEngine',
- 'AlmanacNamespaceEditor' => 'PhabricatorApplicationTransactionEditor',
+ 'AlmanacNamespaceEditor' => 'AlmanacEditor',
'AlmanacNamespaceListController' => 'AlmanacNamespaceController',
'AlmanacNamespaceNameNgrams' => 'PhabricatorSearchNgrams',
'AlmanacNamespaceNameTransaction' => 'AlmanacNamespaceTransactionType',
'AlmanacNamespacePHIDType' => 'PhabricatorPHIDType',
'AlmanacNamespaceQuery' => 'AlmanacQuery',
'AlmanacNamespaceSearchEngine' => 'PhabricatorApplicationSearchEngine',
- 'AlmanacNamespaceTransaction' => 'PhabricatorModularTransaction',
+ 'AlmanacNamespaceTransaction' => 'AlmanacModularTransaction',
'AlmanacNamespaceTransactionQuery' => 'PhabricatorApplicationTransactionQuery',
'AlmanacNamespaceTransactionType' => 'AlmanacTransactionType',
'AlmanacNamespaceViewController' => 'AlmanacNamespaceController',
@@ -5314,14 +5325,14 @@
'AlmanacNetworkController' => 'AlmanacController',
'AlmanacNetworkEditController' => 'AlmanacNetworkController',
'AlmanacNetworkEditEngine' => 'PhabricatorEditEngine',
- 'AlmanacNetworkEditor' => 'PhabricatorApplicationTransactionEditor',
+ 'AlmanacNetworkEditor' => 'AlmanacEditor',
'AlmanacNetworkListController' => 'AlmanacNetworkController',
'AlmanacNetworkNameNgrams' => 'PhabricatorSearchNgrams',
'AlmanacNetworkNameTransaction' => 'AlmanacNetworkTransactionType',
'AlmanacNetworkPHIDType' => 'PhabricatorPHIDType',
'AlmanacNetworkQuery' => 'AlmanacQuery',
'AlmanacNetworkSearchEngine' => 'PhabricatorApplicationSearchEngine',
- 'AlmanacNetworkTransaction' => 'PhabricatorModularTransaction',
+ 'AlmanacNetworkTransaction' => 'AlmanacModularTransaction',
'AlmanacNetworkTransactionQuery' => 'PhabricatorApplicationTransactionQuery',
'AlmanacNetworkTransactionType' => 'AlmanacTransactionType',
'AlmanacNetworkViewController' => 'AlmanacNetworkController',
@@ -5352,6 +5363,7 @@
),
'AlmanacServiceController' => 'AlmanacController',
'AlmanacServiceDatasource' => 'PhabricatorTypeaheadDatasource',
+ 'AlmanacServiceDeletePropertyTransaction' => 'AlmanacServiceTransactionType',
'AlmanacServiceEditController' => 'AlmanacServiceController',
'AlmanacServiceEditEngine' => 'PhabricatorEditEngine',
'AlmanacServiceEditor' => 'AlmanacEditor',
@@ -5363,7 +5375,8 @@
'AlmanacServiceQuery' => 'AlmanacQuery',
'AlmanacServiceSearchConduitAPIMethod' => 'PhabricatorSearchEngineAPIMethod',
'AlmanacServiceSearchEngine' => 'PhabricatorApplicationSearchEngine',
- 'AlmanacServiceTransaction' => 'PhabricatorModularTransaction',
+ 'AlmanacServiceSetPropertyTransaction' => 'AlmanacServiceTransactionType',
+ 'AlmanacServiceTransaction' => 'AlmanacModularTransaction',
'AlmanacServiceTransactionQuery' => 'PhabricatorApplicationTransactionQuery',
'AlmanacServiceTransactionType' => 'AlmanacTransactionType',
'AlmanacServiceType' => 'Phobject',
@@ -5371,7 +5384,6 @@
'AlmanacServiceTypeTestCase' => 'PhabricatorTestCase',
'AlmanacServiceTypeTransaction' => 'AlmanacServiceTransactionType',
'AlmanacServiceViewController' => 'AlmanacServiceController',
- 'AlmanacTransaction' => 'PhabricatorApplicationTransaction',
'AlmanacTransactionType' => 'PhabricatorModularTransactionType',
'AphlictDropdownDataQuery' => 'Phobject',
'Aphront304Response' => 'AphrontResponse',
diff --git a/src/applications/almanac/controller/AlmanacPropertyDeleteController.php b/src/applications/almanac/controller/AlmanacPropertyDeleteController.php
--- a/src/applications/almanac/controller/AlmanacPropertyDeleteController.php
+++ b/src/applications/almanac/controller/AlmanacPropertyDeleteController.php
@@ -39,8 +39,10 @@
$validation_exception = null;
if ($request->isFormPost()) {
+ $xaction_type = $object->getAlmanacPropertyDeleteTransactionType();
+
$xaction = $object->getApplicationTransactionTemplate()
- ->setTransactionType(AlmanacTransaction::TYPE_PROPERTY_REMOVE)
+ ->setTransactionType($xaction_type)
->setMetadataValue('almanac.property', $key);
$editor = $object->getApplicationTransactionEditor()
diff --git a/src/applications/almanac/editor/AlmanacBindingEditor.php b/src/applications/almanac/editor/AlmanacBindingEditor.php
--- a/src/applications/almanac/editor/AlmanacBindingEditor.php
+++ b/src/applications/almanac/editor/AlmanacBindingEditor.php
@@ -15,4 +15,8 @@
return pht('%s created %s.', $author, $object);
}
+ protected function supportsSearch() {
+ return true;
+ }
+
}
diff --git a/src/applications/almanac/editor/AlmanacDeviceEditor.php b/src/applications/almanac/editor/AlmanacDeviceEditor.php
--- a/src/applications/almanac/editor/AlmanacDeviceEditor.php
+++ b/src/applications/almanac/editor/AlmanacDeviceEditor.php
@@ -7,6 +7,18 @@
return pht('Almanac Device');
}
+ public function getCreateObjectTitle($author, $object) {
+ return pht('%s created this device.', $author);
+ }
+
+ public function getCreateObjectTitleForFeed($author, $object) {
+ return pht('%s created %s.', $author, $object);
+ }
+
+ protected function supportsSearch() {
+ return true;
+ }
+
public function getTransactionTypes() {
$types = parent::getTransactionTypes();
diff --git a/src/applications/almanac/editor/AlmanacEditor.php b/src/applications/almanac/editor/AlmanacEditor.php
--- a/src/applications/almanac/editor/AlmanacEditor.php
+++ b/src/applications/almanac/editor/AlmanacEditor.php
@@ -7,150 +7,4 @@
return 'PhabricatorAlmanacApplication';
}
- protected function supportsSearch() {
- return true;
- }
-
- public function getTransactionTypes() {
- $types = parent::getTransactionTypes();
-
- $types[] = AlmanacTransaction::TYPE_PROPERTY_UPDATE;
- $types[] = AlmanacTransaction::TYPE_PROPERTY_REMOVE;
-
- return $types;
- }
-
- protected function getCustomTransactionOldValue(
- PhabricatorLiskDAO $object,
- PhabricatorApplicationTransaction $xaction) {
- switch ($xaction->getTransactionType()) {
- case AlmanacTransaction::TYPE_PROPERTY_UPDATE:
- case AlmanacTransaction::TYPE_PROPERTY_REMOVE:
- $property_key = $xaction->getMetadataValue('almanac.property');
- $exists = $object->hasAlmanacProperty($property_key);
- $value = $object->getAlmanacPropertyValue($property_key);
- return array(
- 'existed' => $exists,
- 'value' => $value,
- );
- }
-
- return parent::getCustomTransactionOldValue($object, $xaction);
- }
-
- protected function getCustomTransactionNewValue(
- PhabricatorLiskDAO $object,
- PhabricatorApplicationTransaction $xaction) {
-
- switch ($xaction->getTransactionType()) {
- case AlmanacTransaction::TYPE_PROPERTY_UPDATE:
- case AlmanacTransaction::TYPE_PROPERTY_REMOVE:
- return $xaction->getNewValue();
- }
-
- return parent::getCustomTransactionNewValue($object, $xaction);
- }
-
- protected function applyCustomInternalTransaction(
- PhabricatorLiskDAO $object,
- PhabricatorApplicationTransaction $xaction) {
-
- switch ($xaction->getTransactionType()) {
- case AlmanacTransaction::TYPE_PROPERTY_UPDATE:
- case AlmanacTransaction::TYPE_PROPERTY_REMOVE:
- return;
- }
-
- return parent::applyCustomInternalTransaction($object, $xaction);
- }
-
- protected function applyCustomExternalTransaction(
- PhabricatorLiskDAO $object,
- PhabricatorApplicationTransaction $xaction) {
-
- switch ($xaction->getTransactionType()) {
- case AlmanacTransaction::TYPE_PROPERTY_UPDATE:
- $property_key = $xaction->getMetadataValue('almanac.property');
- if ($object->hasAlmanacProperty($property_key)) {
- $property = $object->getAlmanacProperty($property_key);
- } else {
- $property = id(new AlmanacProperty())
- ->setObjectPHID($object->getPHID())
- ->setFieldName($property_key);
- }
- $property
- ->setFieldValue($xaction->getNewValue())
- ->save();
- return;
- case AlmanacTransaction::TYPE_PROPERTY_REMOVE:
- $property_key = $xaction->getMetadataValue('almanac.property');
- if ($object->hasAlmanacProperty($property_key)) {
- $property = $object->getAlmanacProperty($property_key);
- $property->delete();
- }
- return;
- }
-
- return parent::applyCustomExternalTransaction($object, $xaction);
- }
-
- protected function validateTransaction(
- PhabricatorLiskDAO $object,
- $type,
- array $xactions) {
-
- $errors = parent::validateTransaction($object, $type, $xactions);
-
- switch ($type) {
- case AlmanacTransaction::TYPE_PROPERTY_UPDATE:
- foreach ($xactions as $xaction) {
- $property_key = $xaction->getMetadataValue('almanac.property');
-
- $message = null;
- try {
- AlmanacNames::validateName($property_key);
- } catch (Exception $ex) {
- $message = $ex->getMessage();
- }
-
- if ($message !== null) {
- $error = new PhabricatorApplicationTransactionValidationError(
- $type,
- pht('Invalid'),
- $message,
- $xaction);
- $errors[] = $error;
- continue;
- }
-
- $new_value = $xaction->getNewValue();
- try {
- phutil_json_encode($new_value);
- } catch (Exception $ex) {
- $message = pht(
- 'Almanac property values must be representable in JSON. %s',
- $ex->getMessage());
- }
-
- if ($message !== null) {
- $error = new PhabricatorApplicationTransactionValidationError(
- $type,
- pht('Invalid'),
- $message,
- $xaction);
- $errors[] = $error;
- continue;
- }
- }
- break;
-
- case AlmanacTransaction::TYPE_PROPERTY_REMOVE:
- // NOTE: No name validation on removals since it's OK to delete
- // an invalid property that somehow came into existence.
- break;
- }
-
- return $errors;
- }
-
}
diff --git a/src/applications/almanac/editor/AlmanacInterfaceEditor.php b/src/applications/almanac/editor/AlmanacInterfaceEditor.php
--- a/src/applications/almanac/editor/AlmanacInterfaceEditor.php
+++ b/src/applications/almanac/editor/AlmanacInterfaceEditor.php
@@ -1,11 +1,7 @@
<?php
final class AlmanacInterfaceEditor
- extends PhabricatorApplicationTransactionEditor {
-
- public function getEditorApplicationClass() {
- return 'PhabricatorAlmanacApplication';
- }
+ extends AlmanacEditor {
public function getEditorObjectsDescription() {
return pht('Almanac Interface');
diff --git a/src/applications/almanac/editor/AlmanacNamespaceEditor.php b/src/applications/almanac/editor/AlmanacNamespaceEditor.php
--- a/src/applications/almanac/editor/AlmanacNamespaceEditor.php
+++ b/src/applications/almanac/editor/AlmanacNamespaceEditor.php
@@ -1,11 +1,7 @@
<?php
final class AlmanacNamespaceEditor
- extends PhabricatorApplicationTransactionEditor {
-
- public function getEditorApplicationClass() {
- return 'PhabricatorAlmanacApplication';
- }
+ extends AlmanacEditor {
public function getEditorObjectsDescription() {
return pht('Almanac Namespace');
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
@@ -1,20 +1,12 @@
<?php
final class AlmanacNetworkEditor
- extends PhabricatorApplicationTransactionEditor {
-
- public function getEditorApplicationClass() {
- return 'PhabricatorAlmanacApplication';
- }
+ extends AlmanacEditor {
public function getEditorObjectsDescription() {
return pht('Almanac Network');
}
- protected function supportsSearch() {
- return true;
- }
-
public function getCreateObjectTitle($author, $object) {
return pht('%s created this network.', $author);
}
@@ -23,6 +15,10 @@
return pht('%s created %s.', $author, $object);
}
+ protected function supportsSearch() {
+ return true;
+ }
+
public function getTransactionTypes() {
$types = parent::getTransactionTypes();
diff --git a/src/applications/almanac/editor/AlmanacPropertyEditEngine.php b/src/applications/almanac/editor/AlmanacPropertyEditEngine.php
--- a/src/applications/almanac/editor/AlmanacPropertyEditEngine.php
+++ b/src/applications/almanac/editor/AlmanacPropertyEditEngine.php
@@ -64,7 +64,7 @@
protected function buildCustomEditFields($object) {
$property_key = $this->getPropertyKey();
- $xaction_type = AlmanacTransaction::TYPE_PROPERTY_UPDATE;
+ $xaction_type = $object->getAlmanacPropertySetTransactionType();
return array(
id(new PhabricatorTextEditField())
diff --git a/src/applications/almanac/property/AlmanacPropertyInterface.php b/src/applications/almanac/property/AlmanacPropertyInterface.php
--- a/src/applications/almanac/property/AlmanacPropertyInterface.php
+++ b/src/applications/almanac/property/AlmanacPropertyInterface.php
@@ -9,5 +9,7 @@
public function getAlmanacPropertyValue($key, $default = null);
public function getAlmanacPropertyFieldSpecifications();
public function newAlmanacPropertyEditEngine();
+ public function getAlmanacPropertySetTransactionType();
+ public function getAlmanacPropertyDeleteTransactionType();
}
diff --git a/src/applications/almanac/storage/AlmanacBinding.php b/src/applications/almanac/storage/AlmanacBinding.php
--- a/src/applications/almanac/storage/AlmanacBinding.php
+++ b/src/applications/almanac/storage/AlmanacBinding.php
@@ -134,6 +134,14 @@
return new AlmanacBindingPropertyEditEngine();
}
+ public function getAlmanacPropertySetTransactionType() {
+ return AlmanacBindingSetPropertyTransaction::TRANSACTIONTYPE;
+ }
+
+ public function getAlmanacPropertyDeleteTransactionType() {
+ return AlmanacBindingDeletePropertyTransaction::TRANSACTIONTYPE;
+ }
+
/* -( PhabricatorPolicyInterface )----------------------------------------- */
diff --git a/src/applications/almanac/storage/AlmanacBindingTransaction.php b/src/applications/almanac/storage/AlmanacBindingTransaction.php
--- a/src/applications/almanac/storage/AlmanacBindingTransaction.php
+++ b/src/applications/almanac/storage/AlmanacBindingTransaction.php
@@ -1,20 +1,12 @@
<?php
final class AlmanacBindingTransaction
- extends PhabricatorModularTransaction {
-
- public function getApplicationName() {
- return 'almanac';
- }
+ extends AlmanacModularTransaction {
public function getApplicationTransactionType() {
return AlmanacBindingPHIDType::TYPECONST;
}
- public function getApplicationTransactionCommentObject() {
- return null;
- }
-
public function getBaseTransactionClass() {
return 'AlmanacBindingTransactionType';
}
diff --git a/src/applications/almanac/storage/AlmanacDevice.php b/src/applications/almanac/storage/AlmanacDevice.php
--- a/src/applications/almanac/storage/AlmanacDevice.php
+++ b/src/applications/almanac/storage/AlmanacDevice.php
@@ -143,6 +143,14 @@
return new AlmanacDevicePropertyEditEngine();
}
+ public function getAlmanacPropertySetTransactionType() {
+ return AlmanacDeviceSetPropertyTransaction::TRANSACTIONTYPE;
+ }
+
+ public function getAlmanacPropertyDeleteTransactionType() {
+ return AlmanacDeviceDeletePropertyTransaction::TRANSACTIONTYPE;
+ }
+
/* -( PhabricatorPolicyInterface )----------------------------------------- */
diff --git a/src/applications/almanac/storage/AlmanacDeviceTransaction.php b/src/applications/almanac/storage/AlmanacDeviceTransaction.php
--- a/src/applications/almanac/storage/AlmanacDeviceTransaction.php
+++ b/src/applications/almanac/storage/AlmanacDeviceTransaction.php
@@ -1,20 +1,12 @@
<?php
final class AlmanacDeviceTransaction
- extends PhabricatorModularTransaction {
-
- public function getApplicationName() {
- return 'almanac';
- }
+ extends AlmanacModularTransaction {
public function getApplicationTransactionType() {
return AlmanacDevicePHIDType::TYPECONST;
}
- public function getApplicationTransactionCommentObject() {
- return null;
- }
-
public function getBaseTransactionClass() {
return 'AlmanacDeviceTransactionType';
}
diff --git a/src/applications/almanac/storage/AlmanacInterfaceTransaction.php b/src/applications/almanac/storage/AlmanacInterfaceTransaction.php
--- a/src/applications/almanac/storage/AlmanacInterfaceTransaction.php
+++ b/src/applications/almanac/storage/AlmanacInterfaceTransaction.php
@@ -1,20 +1,12 @@
<?php
final class AlmanacInterfaceTransaction
- extends PhabricatorModularTransaction {
-
- public function getApplicationName() {
- return 'almanac';
- }
+ extends AlmanacModularTransaction {
public function getApplicationTransactionType() {
return AlmanacInterfacePHIDType::TYPECONST;
}
- public function getApplicationTransactionCommentObject() {
- return null;
- }
-
public function getBaseTransactionClass() {
return 'AlmanacInterfaceTransactionType';
}
diff --git a/src/applications/almanac/storage/AlmanacModularTransaction.php b/src/applications/almanac/storage/AlmanacModularTransaction.php
new file mode 100644
--- /dev/null
+++ b/src/applications/almanac/storage/AlmanacModularTransaction.php
@@ -0,0 +1,14 @@
+<?php
+
+abstract class AlmanacModularTransaction
+ extends PhabricatorModularTransaction {
+
+ public function getApplicationName() {
+ return 'almanac';
+ }
+
+ public function getApplicationTransactionCommentObject() {
+ return null;
+ }
+
+}
diff --git a/src/applications/almanac/storage/AlmanacNamespace.php b/src/applications/almanac/storage/AlmanacNamespace.php
--- a/src/applications/almanac/storage/AlmanacNamespace.php
+++ b/src/applications/almanac/storage/AlmanacNamespace.php
@@ -150,6 +150,14 @@
throw new PhutilMethodNotImplementedException();
}
+ public function getAlmanacPropertySetTransactionType() {
+ throw new PhutilMethodNotImplementedException();
+ }
+
+ public function getAlmanacPropertyDeleteTransactionType() {
+ throw new PhutilMethodNotImplementedException();
+ }
+
/* -( PhabricatorPolicyInterface )----------------------------------------- */
diff --git a/src/applications/almanac/storage/AlmanacNamespaceTransaction.php b/src/applications/almanac/storage/AlmanacNamespaceTransaction.php
--- a/src/applications/almanac/storage/AlmanacNamespaceTransaction.php
+++ b/src/applications/almanac/storage/AlmanacNamespaceTransaction.php
@@ -1,20 +1,12 @@
<?php
final class AlmanacNamespaceTransaction
- extends PhabricatorModularTransaction {
-
- public function getApplicationName() {
- return 'almanac';
- }
+ extends AlmanacModularTransaction {
public function getApplicationTransactionType() {
return AlmanacNamespacePHIDType::TYPECONST;
}
- public function getApplicationTransactionCommentObject() {
- return null;
- }
-
public function getBaseTransactionClass() {
return 'AlmanacNamespaceTransactionType';
}
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,20 +1,12 @@
<?php
final class AlmanacNetworkTransaction
- extends PhabricatorModularTransaction {
-
- public function getApplicationName() {
- return 'almanac';
- }
+ extends AlmanacModularTransaction {
public function getApplicationTransactionType() {
return AlmanacNetworkPHIDType::TYPECONST;
}
- public function getApplicationTransactionCommentObject() {
- return null;
- }
-
public function getBaseTransactionClass() {
return 'AlmanacNetworkTransactionType';
}
diff --git a/src/applications/almanac/storage/AlmanacProperty.php b/src/applications/almanac/storage/AlmanacProperty.php
--- a/src/applications/almanac/storage/AlmanacProperty.php
+++ b/src/applications/almanac/storage/AlmanacProperty.php
@@ -54,7 +54,7 @@
}
$xactions[] = id(clone $template)
- ->setTransactionType(AlmanacTransaction::TYPE_PROPERTY_UPDATE)
+ ->setTransactionType($object->getAlmanacPropertySetTransactionType())
->setMetadataValue('almanac.property', $name)
->setNewValue($property);
}
@@ -71,7 +71,7 @@
$xactions = array();
foreach ($properties as $property) {
$xactions[] = id(clone $template)
- ->setTransactionType(AlmanacTransaction::TYPE_PROPERTY_REMOVE)
+ ->setTransactionType($object->getAlmanacPropertyDeleteTransactionType())
->setMetadataValue('almanac.property', $property)
->setNewValue(null);
}
diff --git a/src/applications/almanac/storage/AlmanacService.php b/src/applications/almanac/storage/AlmanacService.php
--- a/src/applications/almanac/storage/AlmanacService.php
+++ b/src/applications/almanac/storage/AlmanacService.php
@@ -160,6 +160,14 @@
return new AlmanacServicePropertyEditEngine();
}
+ public function getAlmanacPropertySetTransactionType() {
+ return AlmanacServiceSetPropertyTransaction::TRANSACTIONTYPE;
+ }
+
+ public function getAlmanacPropertyDeleteTransactionType() {
+ return AlmanacServiceDeletePropertyTransaction::TRANSACTIONTYPE;
+ }
+
/* -( PhabricatorPolicyInterface )----------------------------------------- */
diff --git a/src/applications/almanac/storage/AlmanacServiceTransaction.php b/src/applications/almanac/storage/AlmanacServiceTransaction.php
--- a/src/applications/almanac/storage/AlmanacServiceTransaction.php
+++ b/src/applications/almanac/storage/AlmanacServiceTransaction.php
@@ -1,15 +1,7 @@
<?php
final class AlmanacServiceTransaction
- extends PhabricatorModularTransaction {
-
- public function getApplicationName() {
- return 'almanac';
- }
-
- public function getApplicationTransactionCommentObject() {
- return null;
- }
+ extends AlmanacModularTransaction {
public function getApplicationTransactionType() {
return AlmanacServicePHIDType::TYPECONST;
diff --git a/src/applications/almanac/storage/AlmanacTransaction.php b/src/applications/almanac/storage/AlmanacTransaction.php
deleted file mode 100644
--- a/src/applications/almanac/storage/AlmanacTransaction.php
+++ /dev/null
@@ -1,38 +0,0 @@
-<?php
-
-abstract class AlmanacTransaction
- extends PhabricatorApplicationTransaction {
-
- const TYPE_PROPERTY_UPDATE = 'almanac:property:update';
- const TYPE_PROPERTY_REMOVE = 'almanac:property:remove';
-
- public function getApplicationName() {
- return 'almanac';
- }
-
- public function getApplicationTransactionCommentObject() {
- return null;
- }
-
- public function getTitle() {
- $author_phid = $this->getAuthorPHID();
-
- switch ($this->getTransactionType()) {
- case self::TYPE_PROPERTY_UPDATE:
- $property_key = $this->getMetadataValue('almanac.property');
- return pht(
- '%s updated the property "%s".',
- $this->renderHandleLink($author_phid),
- $property_key);
- case self::TYPE_PROPERTY_REMOVE:
- $property_key = $this->getMetadataValue('almanac.property');
- return pht(
- '%s deleted the property "%s".',
- $this->renderHandleLink($author_phid),
- $property_key);
- }
-
- return parent::getTitle();
- }
-
-}
diff --git a/src/applications/almanac/xaction/AlmanacBindingDeletePropertyTransaction.php b/src/applications/almanac/xaction/AlmanacBindingDeletePropertyTransaction.php
new file mode 100644
--- /dev/null
+++ b/src/applications/almanac/xaction/AlmanacBindingDeletePropertyTransaction.php
@@ -0,0 +1,20 @@
+<?php
+
+final class AlmanacBindingDeletePropertyTransaction
+ extends AlmanacBindingTransactionType {
+
+ const TRANSACTIONTYPE = 'almanac:property:remove';
+
+ public function generateOldValue($object) {
+ return $this->getAlmanacPropertyOldValue($object);
+ }
+
+ public function applyInternalEffects($object, $value) {
+ return $this->deleteAlmanacProperty($object);
+ }
+
+ public function getTitle() {
+ return $this->getAlmanacDeletePropertyTitle();
+ }
+
+}
diff --git a/src/applications/almanac/xaction/AlmanacBindingSetPropertyTransaction.php b/src/applications/almanac/xaction/AlmanacBindingSetPropertyTransaction.php
new file mode 100644
--- /dev/null
+++ b/src/applications/almanac/xaction/AlmanacBindingSetPropertyTransaction.php
@@ -0,0 +1,24 @@
+<?php
+
+final class AlmanacBindingSetPropertyTransaction
+ extends AlmanacBindingTransactionType {
+
+ const TRANSACTIONTYPE = 'almanac:property:update';
+
+ public function generateOldValue($object) {
+ return $this->getAlmanacPropertyOldValue($object);
+ }
+
+ public function applyExternalEffects($object, $value) {
+ return $this->setAlmanacProperty($object, $value);
+ }
+
+ public function getTitle() {
+ return $this->getAlmanacSetPropertyTitle();
+ }
+
+ public function validateTransactions($object, array $xactions) {
+ return $this->validateAlmanacSetPropertyTransactions($object, $xactions);
+ }
+
+}
diff --git a/src/applications/almanac/xaction/AlmanacDeviceDeletePropertyTransaction.php b/src/applications/almanac/xaction/AlmanacDeviceDeletePropertyTransaction.php
new file mode 100644
--- /dev/null
+++ b/src/applications/almanac/xaction/AlmanacDeviceDeletePropertyTransaction.php
@@ -0,0 +1,20 @@
+<?php
+
+final class AlmanacDeviceDeletePropertyTransaction
+ extends AlmanacDeviceTransactionType {
+
+ const TRANSACTIONTYPE = 'almanac:property:remove';
+
+ public function generateOldValue($object) {
+ return $this->getAlmanacPropertyOldValue($object);
+ }
+
+ public function applyInternalEffects($object, $value) {
+ return $this->deleteAlmanacProperty($object);
+ }
+
+ public function getTitle() {
+ return $this->getAlmanacDeletePropertyTitle();
+ }
+
+}
diff --git a/src/applications/almanac/xaction/AlmanacDeviceSetPropertyTransaction.php b/src/applications/almanac/xaction/AlmanacDeviceSetPropertyTransaction.php
new file mode 100644
--- /dev/null
+++ b/src/applications/almanac/xaction/AlmanacDeviceSetPropertyTransaction.php
@@ -0,0 +1,24 @@
+<?php
+
+final class AlmanacDeviceSetPropertyTransaction
+ extends AlmanacDeviceTransactionType {
+
+ const TRANSACTIONTYPE = 'almanac:property:update';
+
+ public function generateOldValue($object) {
+ return $this->getAlmanacPropertyOldValue($object);
+ }
+
+ public function applyExternalEffects($object, $value) {
+ return $this->setAlmanacProperty($object, $value);
+ }
+
+ public function getTitle() {
+ return $this->getAlmanacSetPropertyTitle();
+ }
+
+ public function validateTransactions($object, array $xactions) {
+ return $this->validateAlmanacSetPropertyTransactions($object, $xactions);
+ }
+
+}
diff --git a/src/applications/almanac/xaction/AlmanacServiceDeletePropertyTransaction.php b/src/applications/almanac/xaction/AlmanacServiceDeletePropertyTransaction.php
new file mode 100644
--- /dev/null
+++ b/src/applications/almanac/xaction/AlmanacServiceDeletePropertyTransaction.php
@@ -0,0 +1,20 @@
+<?php
+
+final class AlmanacServiceDeletePropertyTransaction
+ extends AlmanacServiceTransactionType {
+
+ const TRANSACTIONTYPE = 'almanac:property:remove';
+
+ public function generateOldValue($object) {
+ return $this->getAlmanacPropertyOldValue($object);
+ }
+
+ public function applyInternalEffects($object, $value) {
+ return $this->deleteAlmanacProperty($object);
+ }
+
+ public function getTitle() {
+ return $this->getAlmanacDeletePropertyTitle();
+ }
+
+}
diff --git a/src/applications/almanac/xaction/AlmanacServiceSetPropertyTransaction.php b/src/applications/almanac/xaction/AlmanacServiceSetPropertyTransaction.php
new file mode 100644
--- /dev/null
+++ b/src/applications/almanac/xaction/AlmanacServiceSetPropertyTransaction.php
@@ -0,0 +1,24 @@
+<?php
+
+final class AlmanacServiceSetPropertyTransaction
+ extends AlmanacServiceTransactionType {
+
+ const TRANSACTIONTYPE = 'almanac:property:update';
+
+ public function generateOldValue($object) {
+ return $this->getAlmanacPropertyOldValue($object);
+ }
+
+ public function applyExternalEffects($object, $value) {
+ return $this->setAlmanacProperty($object, $value);
+ }
+
+ public function getTitle() {
+ return $this->getAlmanacSetPropertyTitle();
+ }
+
+ public function validateTransactions($object, array $xactions) {
+ return $this->validateAlmanacSetPropertyTransactions($object, $xactions);
+ }
+
+}
diff --git a/src/applications/almanac/xaction/AlmanacTransactionType.php b/src/applications/almanac/xaction/AlmanacTransactionType.php
--- a/src/applications/almanac/xaction/AlmanacTransactionType.php
+++ b/src/applications/almanac/xaction/AlmanacTransactionType.php
@@ -1,4 +1,97 @@
<?php
abstract class AlmanacTransactionType
- extends PhabricatorModularTransactionType {}
+ extends PhabricatorModularTransactionType {
+
+ protected function getAlmanacPropertyOldValue($object) {
+ $property_key = $this->getMetadataValue('almanac.property');
+ $exists = $object->hasAlmanacProperty($property_key);
+ $value = $object->getAlmanacPropertyValue($property_key);
+
+ return array(
+ 'existed' => $exists,
+ 'value' => $value,
+ );
+ }
+
+ protected function setAlmanacProperty($object, $value) {
+ $property_key = $this->getMetadataValue('almanac.property');
+
+ if ($object->hasAlmanacProperty($property_key)) {
+ $property = $object->getAlmanacProperty($property_key);
+ } else {
+ $property = id(new AlmanacProperty())
+ ->setObjectPHID($object->getPHID())
+ ->setFieldName($property_key);
+ }
+
+ $property
+ ->setFieldValue($value)
+ ->save();
+ }
+
+ protected function deleteAlmanacProperty($object) {
+ $property_key = $this->getMetadataValue('almanac.property');
+ if ($object->hasAlmanacProperty($property_key)) {
+ $property = $object->getAlmanacProperty($property_key);
+ $property->delete();
+ }
+ }
+
+ protected function getAlmanacSetPropertyTitle() {
+ $property_key = $this->getMetadataValue('almanac.property');
+
+ return pht(
+ '%s updated the property %s.',
+ $this->renderAuthor(),
+ $this->renderValue($property_key));
+ }
+
+ protected function getAlmanacDeletePropertyTitle() {
+ $property_key = $this->getMetadataValue('almanac.property');
+
+ return pht(
+ '%s removed the property %s.',
+ $this->renderAuthor(),
+ $this->renderValue($property_key));
+ }
+
+ protected function validateAlmanacSetPropertyTransactions(
+ $object,
+ array $xactions) {
+ $errors = array();
+
+ foreach ($xactions as $xaction) {
+ $property_key = $xaction->getMetadataValue('almanac.property');
+
+ $message = null;
+ try {
+ AlmanacNames::validateName($property_key);
+ } catch (Exception $ex) {
+ $message = $ex->getMessage();
+ }
+
+ if ($message !== null) {
+ $errors[] = $this->newInvalidError($message, $xaction);
+ continue;
+ }
+
+ $new_value = $xaction->getNewValue();
+ try {
+ phutil_json_encode($new_value);
+ } catch (Exception $ex) {
+ $message = pht(
+ 'Almanac property values must be representable in JSON. %s',
+ $ex->getMessage());
+ }
+
+ if ($message !== null) {
+ $errors[] = $this->newInvalidError($message, $xaction);
+ continue;
+ }
+ }
+
+ return $errors;
+ }
+
+}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Oct 4 2025, 9:29 AM (7 w, 3 d ago)
Storage Engine
amazon-s3
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
phabricator/secure/hw/32/fgsmyxgf7g64dluu
Default Alt Text
D19334.diff (40 KB)
Attached To
Mode
D19334: Modularize Almanac property transactions
Attached
Detach File
Event Timeline
Log In to Comment