From eda64b85497b82782a24ffe8e0f276e4423d3c46 Mon Sep 17 00:00:00 2001 From: epriestley Date: Tue, 13 Dec 2016 12:11:17 -0800 Subject: [PATCH] Add a very basic EditPro controller for Differential Summary: Ref T11114. This doesn't really support anything yet, but technically works if you manually go to `/editpro/`. Test Plan: {F2117302} Reviewers: chad Reviewed By: chad Maniphest Tasks: T11114 Differential Revision: https://secure.phabricator.com/D17043 --- src/__phutil_library_map__.php | 4 ++ .../PhabricatorDifferentialApplication.php | 2 + .../DifferentialRevisionEditProController.php | 12 ++++ .../editor/DifferentialRevisionEditEngine.php | 66 +++++++++++++++++++ ...bricatorCustomFieldEditEngineExtension.php | 6 ++ 5 files changed, 90 insertions(+) create mode 100644 src/applications/differential/controller/DifferentialRevisionEditProController.php create mode 100644 src/applications/differential/editor/DifferentialRevisionEditEngine.php diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 00f67fbe29..39624fb9ab 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -518,6 +518,8 @@ phutil_register_library_map(array( 'DifferentialRevisionDependedOnByRevisionEdgeType' => 'applications/differential/edge/DifferentialRevisionDependedOnByRevisionEdgeType.php', 'DifferentialRevisionDependsOnRevisionEdgeType' => 'applications/differential/edge/DifferentialRevisionDependsOnRevisionEdgeType.php', 'DifferentialRevisionEditController' => 'applications/differential/controller/DifferentialRevisionEditController.php', + 'DifferentialRevisionEditEngine' => 'applications/differential/editor/DifferentialRevisionEditEngine.php', + 'DifferentialRevisionEditProController' => 'applications/differential/controller/DifferentialRevisionEditProController.php', 'DifferentialRevisionFulltextEngine' => 'applications/differential/search/DifferentialRevisionFulltextEngine.php', 'DifferentialRevisionGraph' => 'infrastructure/graph/DifferentialRevisionGraph.php', 'DifferentialRevisionHasChildRelationship' => 'applications/differential/relationships/DifferentialRevisionHasChildRelationship.php', @@ -5164,6 +5166,8 @@ phutil_register_library_map(array( 'DifferentialRevisionDependedOnByRevisionEdgeType' => 'PhabricatorEdgeType', 'DifferentialRevisionDependsOnRevisionEdgeType' => 'PhabricatorEdgeType', 'DifferentialRevisionEditController' => 'DifferentialController', + 'DifferentialRevisionEditEngine' => 'PhabricatorEditEngine', + 'DifferentialRevisionEditProController' => 'DifferentialController', 'DifferentialRevisionFulltextEngine' => 'PhabricatorFulltextEngine', 'DifferentialRevisionGraph' => 'PhabricatorObjectGraph', 'DifferentialRevisionHasChildRelationship' => 'DifferentialRevisionRelationship', diff --git a/src/applications/differential/application/PhabricatorDifferentialApplication.php b/src/applications/differential/application/PhabricatorDifferentialApplication.php index 589dfe239d..d72fd2ddc8 100644 --- a/src/applications/differential/application/PhabricatorDifferentialApplication.php +++ b/src/applications/differential/application/PhabricatorDifferentialApplication.php @@ -67,6 +67,8 @@ final class PhabricatorDifferentialApplication extends PhabricatorApplication { 'revision/' => array( 'edit/(?:(?P[1-9]\d*)/)?' => 'DifferentialRevisionEditController', + $this->getEditRoutePattern('editpro/') + => 'DifferentialRevisionEditProController', 'land/(?:(?P[1-9]\d*))/(?P[^/]+)/' => 'DifferentialRevisionLandController', 'closedetails/(?P[^/]+)/' diff --git a/src/applications/differential/controller/DifferentialRevisionEditProController.php b/src/applications/differential/controller/DifferentialRevisionEditProController.php new file mode 100644 index 0000000000..9c1257dac9 --- /dev/null +++ b/src/applications/differential/controller/DifferentialRevisionEditProController.php @@ -0,0 +1,12 @@ +setController($this) + ->buildResponse(); + } + +} diff --git a/src/applications/differential/editor/DifferentialRevisionEditEngine.php b/src/applications/differential/editor/DifferentialRevisionEditEngine.php new file mode 100644 index 0000000000..8953dc4242 --- /dev/null +++ b/src/applications/differential/editor/DifferentialRevisionEditEngine.php @@ -0,0 +1,66 @@ +getViewer(); + return DifferentialRevision::initializeNewRevision($viewer); + } + + protected function newObjectQuery() { + return new DifferentialRevisionQuery(); + } + + protected function getObjectCreateTitleText($object) { + return pht('Create New Revision'); + } + + protected function getObjectEditTitleText($object) { + return pht('Edit Revision: %s', $object->getTitle()); + } + + protected function getObjectEditShortText($object) { + return $object->getMonogram(); + } + + protected function getObjectCreateShortText() { + return pht('Create Revision'); + } + + protected function getObjectName() { + return pht('Revision'); + } + + protected function getObjectViewURI($object) { + return $object->getURI(); + } + + protected function buildCustomEditFields($object) { + return array(); + } + +} diff --git a/src/infrastructure/customfield/engineextension/PhabricatorCustomFieldEditEngineExtension.php b/src/infrastructure/customfield/engineextension/PhabricatorCustomFieldEditEngineExtension.php index b9427905b8..b38eb2961f 100644 --- a/src/infrastructure/customfield/engineextension/PhabricatorCustomFieldEditEngineExtension.php +++ b/src/infrastructure/customfield/engineextension/PhabricatorCustomFieldEditEngineExtension.php @@ -27,6 +27,12 @@ final class PhabricatorCustomFieldEditEngineExtension PhabricatorEditEngine $engine, PhabricatorApplicationTransactionInterface $object) { + // TODO: Remove this hack once Differential modernizes more fully. Today, + // its custom fields are too custom to interact cleanly with EditEngine. + if ($object instanceof DifferentialRevision) { + return array(); + } + $viewer = $this->getViewer(); $field_list = PhabricatorCustomField::getObjectFields(