Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15418033
D19343.id46281.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
10 KB
Referenced Files
None
Subscribers
None
D19343.id46281.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
@@ -44,6 +44,8 @@
'AlmanacCreateServicesCapability' => 'applications/almanac/capability/AlmanacCreateServicesCapability.php',
'AlmanacCustomServiceType' => 'applications/almanac/servicetype/AlmanacCustomServiceType.php',
'AlmanacDAO' => 'applications/almanac/storage/AlmanacDAO.php',
+ 'AlmanacDeletePropertyEditField' => 'applications/almanac/engineextension/AlmanacDeletePropertyEditField.php',
+ 'AlmanacDeletePropertyEditType' => 'applications/almanac/engineextension/AlmanacDeletePropertyEditType.php',
'AlmanacDevice' => 'applications/almanac/storage/AlmanacDevice.php',
'AlmanacDeviceController' => 'applications/almanac/controller/AlmanacDeviceController.php',
'AlmanacDeviceDeletePropertyTransaction' => 'applications/almanac/xaction/AlmanacDeviceDeletePropertyTransaction.php',
@@ -129,6 +131,7 @@
'AlmanacNetworkTransactionType' => 'applications/almanac/xaction/AlmanacNetworkTransactionType.php',
'AlmanacNetworkViewController' => 'applications/almanac/controller/AlmanacNetworkViewController.php',
'AlmanacPropertiesDestructionEngineExtension' => 'applications/almanac/engineextension/AlmanacPropertiesDestructionEngineExtension.php',
+ 'AlmanacPropertiesEditEngineExtension' => 'applications/almanac/engineextension/AlmanacPropertiesEditEngineExtension.php',
'AlmanacPropertiesSearchEngineAttachment' => 'applications/almanac/engineextension/AlmanacPropertiesSearchEngineAttachment.php',
'AlmanacProperty' => 'applications/almanac/storage/AlmanacProperty.php',
'AlmanacPropertyController' => 'applications/almanac/controller/AlmanacPropertyController.php',
@@ -165,6 +168,8 @@
'AlmanacServiceTypeTestCase' => 'applications/almanac/servicetype/__tests__/AlmanacServiceTypeTestCase.php',
'AlmanacServiceTypeTransaction' => 'applications/almanac/xaction/AlmanacServiceTypeTransaction.php',
'AlmanacServiceViewController' => 'applications/almanac/controller/AlmanacServiceViewController.php',
+ 'AlmanacSetPropertyEditField' => 'applications/almanac/engineextension/AlmanacSetPropertyEditField.php',
+ 'AlmanacSetPropertyEditType' => 'applications/almanac/engineextension/AlmanacSetPropertyEditType.php',
'AlmanacTransactionType' => 'applications/almanac/xaction/AlmanacTransactionType.php',
'AphlictDropdownDataQuery' => 'applications/aphlict/query/AphlictDropdownDataQuery.php',
'Aphront304Response' => 'aphront/response/Aphront304Response.php',
@@ -5246,6 +5251,8 @@
'AlmanacCreateServicesCapability' => 'PhabricatorPolicyCapability',
'AlmanacCustomServiceType' => 'AlmanacServiceType',
'AlmanacDAO' => 'PhabricatorLiskDAO',
+ 'AlmanacDeletePropertyEditField' => 'PhabricatorEditField',
+ 'AlmanacDeletePropertyEditType' => 'PhabricatorEditType',
'AlmanacDevice' => array(
'AlmanacDAO',
'PhabricatorPolicyInterface',
@@ -5365,6 +5372,7 @@
'AlmanacNetworkTransactionType' => 'AlmanacTransactionType',
'AlmanacNetworkViewController' => 'AlmanacNetworkController',
'AlmanacPropertiesDestructionEngineExtension' => 'PhabricatorDestructionEngineExtension',
+ 'AlmanacPropertiesEditEngineExtension' => 'PhabricatorEditEngineExtension',
'AlmanacPropertiesSearchEngineAttachment' => 'AlmanacSearchEngineAttachment',
'AlmanacProperty' => array(
'AlmanacDAO',
@@ -5413,6 +5421,8 @@
'AlmanacServiceTypeTestCase' => 'PhabricatorTestCase',
'AlmanacServiceTypeTransaction' => 'AlmanacServiceTransactionType',
'AlmanacServiceViewController' => 'AlmanacServiceController',
+ 'AlmanacSetPropertyEditField' => 'PhabricatorEditField',
+ 'AlmanacSetPropertyEditType' => 'PhabricatorEditType',
'AlmanacTransactionType' => 'PhabricatorModularTransactionType',
'AphlictDropdownDataQuery' => 'Phobject',
'Aphront304Response' => 'AphrontResponse',
diff --git a/src/applications/almanac/editor/AlmanacBindingEditEngine.php b/src/applications/almanac/editor/AlmanacBindingEditEngine.php
--- a/src/applications/almanac/editor/AlmanacBindingEditEngine.php
+++ b/src/applications/almanac/editor/AlmanacBindingEditEngine.php
@@ -91,7 +91,8 @@
}
protected function newObjectQuery() {
- return new AlmanacBindingQuery();
+ return id(new AlmanacBindingQuery())
+ ->needProperties(true);
}
protected function getObjectCreateTitleText($object) {
diff --git a/src/applications/almanac/editor/AlmanacDeviceEditEngine.php b/src/applications/almanac/editor/AlmanacDeviceEditEngine.php
--- a/src/applications/almanac/editor/AlmanacDeviceEditEngine.php
+++ b/src/applications/almanac/editor/AlmanacDeviceEditEngine.php
@@ -30,7 +30,8 @@
}
protected function newObjectQuery() {
- return new AlmanacDeviceQuery();
+ return id(new AlmanacDeviceQuery())
+ ->needProperties(true);
}
protected function getObjectCreateTitleText($object) {
diff --git a/src/applications/almanac/editor/AlmanacServiceEditEngine.php b/src/applications/almanac/editor/AlmanacServiceEditEngine.php
--- a/src/applications/almanac/editor/AlmanacServiceEditEngine.php
+++ b/src/applications/almanac/editor/AlmanacServiceEditEngine.php
@@ -79,7 +79,8 @@
}
protected function newObjectQuery() {
- return new AlmanacServiceQuery();
+ return id(new AlmanacServiceQuery())
+ ->needProperties(true);
}
protected function getObjectCreateTitleText($object) {
diff --git a/src/applications/almanac/engineextension/AlmanacDeletePropertyEditField.php b/src/applications/almanac/engineextension/AlmanacDeletePropertyEditField.php
new file mode 100644
--- /dev/null
+++ b/src/applications/almanac/engineextension/AlmanacDeletePropertyEditField.php
@@ -0,0 +1,22 @@
+<?php
+
+final class AlmanacDeletePropertyEditField
+ extends PhabricatorEditField {
+
+ protected function newControl() {
+ return null;
+ }
+
+ protected function newHTTPParameterType() {
+ return null;
+ }
+
+ protected function newConduitParameterType() {
+ return new ConduitStringListParameterType();
+ }
+
+ protected function newEditType() {
+ return new AlmanacDeletePropertyEditType();
+ }
+
+}
diff --git a/src/applications/almanac/engineextension/AlmanacDeletePropertyEditType.php b/src/applications/almanac/engineextension/AlmanacDeletePropertyEditType.php
new file mode 100644
--- /dev/null
+++ b/src/applications/almanac/engineextension/AlmanacDeletePropertyEditType.php
@@ -0,0 +1,36 @@
+<?php
+
+final class AlmanacDeletePropertyEditType
+ extends PhabricatorEditType {
+
+ public function generateTransactions(
+ PhabricatorApplicationTransaction $template,
+ array $spec) {
+
+ $value = idx($spec, 'value');
+ if (!is_array($value)) {
+ throw new Exception(
+ pht(
+ 'Transaction value when deleting Almanac properties must be a list '.
+ 'of property names.'));
+ }
+
+ $xactions = array();
+ foreach ($value as $idx => $property_key) {
+ if (!is_string($property_key)) {
+ throw new Exception(
+ pht(
+ 'When deleting Almanac properties, each property name must '.
+ 'be a string. The value at index "%s" is not a string.',
+ $idx));
+ }
+
+ $xactions[] = $this->newTransaction($template)
+ ->setMetadataValue('almanac.property', $property_key)
+ ->setNewValue(true);
+ }
+
+ return $xactions;
+ }
+
+}
diff --git a/src/applications/almanac/engineextension/AlmanacPropertiesEditEngineExtension.php b/src/applications/almanac/engineextension/AlmanacPropertiesEditEngineExtension.php
new file mode 100644
--- /dev/null
+++ b/src/applications/almanac/engineextension/AlmanacPropertiesEditEngineExtension.php
@@ -0,0 +1,44 @@
+<?php
+
+final class AlmanacPropertiesEditEngineExtension
+ extends PhabricatorEditEngineExtension {
+
+ const EXTENSIONKEY = 'almanac.properties';
+
+ public function isExtensionEnabled() {
+ return true;
+ }
+
+ public function getExtensionName() {
+ return pht('Almanac Properties');
+ }
+
+ public function supportsObject(
+ PhabricatorEditEngine $engine,
+ PhabricatorApplicationTransactionInterface $object) {
+ return ($object instanceof AlmanacPropertyInterface);
+ }
+
+ public function buildCustomEditFields(
+ PhabricatorEditEngine $engine,
+ PhabricatorApplicationTransactionInterface $object) {
+
+ return array(
+ id(new AlmanacSetPropertyEditField())
+ ->setKey('property.set')
+ ->setTransactionType($object->getAlmanacPropertySetTransactionType())
+ ->setConduitDescription(
+ pht('Pass a map of values to set one or more properties.'))
+ ->setConduitTypeDescription(pht('Map of property names to values.'))
+ ->setIsConduitOnly(true),
+ id(new AlmanacDeletePropertyEditField())
+ ->setKey('property.delete')
+ ->setTransactionType($object->getAlmanacPropertyDeleteTransactionType())
+ ->setConduitDescription(
+ pht('Pass a list of property names to delete properties.'))
+ ->setConduitTypeDescription(pht('List of property names.'))
+ ->setIsConduitOnly(true),
+ );
+ }
+
+}
diff --git a/src/applications/almanac/engineextension/AlmanacSetPropertyEditField.php b/src/applications/almanac/engineextension/AlmanacSetPropertyEditField.php
new file mode 100644
--- /dev/null
+++ b/src/applications/almanac/engineextension/AlmanacSetPropertyEditField.php
@@ -0,0 +1,22 @@
+<?php
+
+final class AlmanacSetPropertyEditField
+ extends PhabricatorEditField {
+
+ protected function newControl() {
+ return null;
+ }
+
+ protected function newHTTPParameterType() {
+ return null;
+ }
+
+ protected function newConduitParameterType() {
+ return new ConduitWildParameterType();
+ }
+
+ protected function newEditType() {
+ return new AlmanacSetPropertyEditType();
+ }
+
+}
diff --git a/src/applications/almanac/engineextension/AlmanacSetPropertyEditType.php b/src/applications/almanac/engineextension/AlmanacSetPropertyEditType.php
new file mode 100644
--- /dev/null
+++ b/src/applications/almanac/engineextension/AlmanacSetPropertyEditType.php
@@ -0,0 +1,28 @@
+<?php
+
+final class AlmanacSetPropertyEditType
+ extends PhabricatorEditType {
+
+ public function generateTransactions(
+ PhabricatorApplicationTransaction $template,
+ array $spec) {
+
+ $value = idx($spec, 'value');
+ if (!is_array($value)) {
+ throw new Exception(
+ pht(
+ 'Transaction value when setting Almanac properties must be a map '.
+ 'with property names as keys.'));
+ }
+
+ $xactions = array();
+ foreach ($value as $property_key => $property_value) {
+ $xactions[] = $this->newTransaction($template)
+ ->setMetadataValue('almanac.property', $property_key)
+ ->setNewValue($property_value);
+ }
+
+ return $xactions;
+ }
+
+}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Mar 21, 8:21 PM (2 w, 1 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7709850
Default Alt Text
D19343.id46281.diff (10 KB)
Attached To
Mode
D19343: Allow Almanac properties to be set and deleted via Conduit
Attached
Detach File
Event Timeline
Log In to Comment