From 01eedd6e6ad004b33c88c4c57cbbf204b6ccff71 Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 16 Sep 2013 16:05:29 -0700 Subject: [PATCH] Make ManiphestCustomField actually implement the interface it ostensibly exposes Summary: There's a bunch of stuff that lives only in AuxiliaryField which is called on objects which may be ManiphestCustomFields right now. This is basically a list of remaining API methods which need to be moved to the new stuff. This enables construction of new-style custom fields. Test Plan: Created a sophisticated Maniphest custom field. Reviewers: btrahan Reviewed By: btrahan CC: aran Differential Revision: https://secure.phabricator.com/D7013 --- .../ManiphestAuxiliaryFieldSpecification.php | 49 ------------- .../editor/ManiphestTransactionEditor.php | 7 ++ .../maniphest/field/ManiphestCustomField.php | 72 +++++++++++++++++++ .../view/ManiphestTransactionDetailView.php | 2 +- 4 files changed, 80 insertions(+), 50 deletions(-) diff --git a/src/applications/maniphest/auxiliaryfield/ManiphestAuxiliaryFieldSpecification.php b/src/applications/maniphest/auxiliaryfield/ManiphestAuxiliaryFieldSpecification.php index 82cdda49fa..18ab1d2915 100644 --- a/src/applications/maniphest/auxiliaryfield/ManiphestAuxiliaryFieldSpecification.php +++ b/src/applications/maniphest/auxiliaryfield/ManiphestAuxiliaryFieldSpecification.php @@ -88,55 +88,6 @@ abstract class ManiphestAuxiliaryFieldSpecification return $this->getValue(); } - - /** - * Render a verb to appear in email titles when a transaction involving this - * field occurs. Specifically, Maniphest emails are formatted like this: - * - * [Maniphest] [Verb Here] TNNN: Task title here - * ^^^^^^^^^ - * - * You should optionally return a title-case verb or short phrase like - * "Created", "Retitled", "Closed", "Resolved", "Commented On", - * "Lowered Priority", etc., which describes the transaction. - * - * @param ManiphestTransaction The transaction which needs description. - * @return string|null A short description of the transaction. - */ - public function renderTransactionEmailVerb( - ManiphestTransaction $transaction) { - return null; - } - - - /** - * Render a short description of the transaction, to appear above comments - * in the Maniphest transaction log. The string will be rendered after the - * acting user's name. Examples are: - * - * added a comment - * added alincoln to CC - * claimed this task - * created this task - * closed this task out of spite - * - * You should return a similar string, describing the transaction. - * - * Note the ##$target## parameter -- Maniphest needs to render transaction - * descriptions for different targets, like web and email. This method will - * be called with a ##ManiphestAuxiliaryFieldSpecification::RENDER_TARGET_*## - * constant describing the intended target. - * - * @param ManiphestTransaction The transaction which needs description. - * @param const Constant describing the rendering target (e.g., html or text). - * @return string|null Description of the transaction. - */ - public function renderTransactionDescription( - ManiphestTransaction $transaction, - $target) { - return 'updated a custom field'; - } - public function getRequiredHandlePHIDs() { return array(); } diff --git a/src/applications/maniphest/editor/ManiphestTransactionEditor.php b/src/applications/maniphest/editor/ManiphestTransactionEditor.php index b5bf62f196..00034da47f 100644 --- a/src/applications/maniphest/editor/ManiphestTransactionEditor.php +++ b/src/applications/maniphest/editor/ManiphestTransactionEditor.php @@ -212,6 +212,13 @@ final class ManiphestTransactionEditor extends PhabricatorEditor { id(new PhabricatorSearchIndexer()) ->indexDocumentByPHID($task->getPHID()); + + $fields = PhabricatorCustomField::getObjectFields( + $task, + PhabricatorCustomField::ROLE_APPLICATIONSEARCH); + $fields->readFieldsFromStorage($task); + $fields->rebuildIndexes($task); + } protected function getSubjectPrefix() { diff --git a/src/applications/maniphest/field/ManiphestCustomField.php b/src/applications/maniphest/field/ManiphestCustomField.php index 6fd679f0a5..103d4934b3 100644 --- a/src/applications/maniphest/field/ManiphestCustomField.php +++ b/src/applications/maniphest/field/ManiphestCustomField.php @@ -28,5 +28,77 @@ abstract class ManiphestCustomField return false; } + // TODO: All of this is legacy junk. + public function getRequiredHandlePHIDs() { + return array(); + } + + public function setHandles(array $handles) { + } + + public function isRequired() { + return false; + } + + public function renderControl() { + return $this->renderEditControl(); + } + + public function validate() { + return true; + } + + /** + * Render a verb to appear in email titles when a transaction involving this + * field occurs. Specifically, Maniphest emails are formatted like this: + * + * [Maniphest] [Verb Here] TNNN: Task title here + * ^^^^^^^^^ + * + * You should optionally return a title-case verb or short phrase like + * "Created", "Retitled", "Closed", "Resolved", "Commented On", + * "Lowered Priority", etc., which describes the transaction. + * + * @param ManiphestTransaction The transaction which needs description. + * @return string|null A short description of the transaction. + */ + public function renderTransactionEmailVerb( + ManiphestTransaction $transaction) { + return null; + } + + + /** + * Render a short description of the transaction, to appear above comments + * in the Maniphest transaction log. The string will be rendered after the + * acting user's name. Examples are: + * + * added a comment + * added alincoln to CC + * claimed this task + * created this task + * closed this task out of spite + * + * You should return a similar string, describing the transaction. + * + * Note the ##$target## parameter -- Maniphest needs to render transaction + * descriptions for different targets, like web and email. This method will + * be called with a ##ManiphestAuxiliaryFieldSpecification::RENDER_TARGET_*## + * constant describing the intended target. + * + * @param ManiphestTransaction The transaction which needs description. + * @param const Constant describing the rendering target (e.g., html or text). + * @return string|null Description of the transaction. + */ + public function renderTransactionDescription( + ManiphestTransaction $transaction, + $target) { + return 'updated a custom field'; + } + + public function getMarkupFields() { + return array(); + } + } diff --git a/src/applications/maniphest/view/ManiphestTransactionDetailView.php b/src/applications/maniphest/view/ManiphestTransactionDetailView.php index f08bcb1f95..b4feeb349c 100644 --- a/src/applications/maniphest/view/ManiphestTransactionDetailView.php +++ b/src/applications/maniphest/view/ManiphestTransactionDetailView.php @@ -20,7 +20,7 @@ final class ManiphestTransactionDetailView extends ManiphestView { public function setAuxiliaryFields(array $fields) { assert_instances_of($fields, 'ManiphestCustomField'); - $this->auxiliaryFields = mpull($fields, null, 'getAuxiliaryKey'); + $this->auxiliaryFields = mpull($fields, null, 'getFieldKey'); return $this; }