From 5651141520cc4d7b80591ccb17fca1eab795a099 Mon Sep 17 00:00:00 2001 From: epriestley Date: Tue, 10 Sep 2013 15:31:48 -0700 Subject: [PATCH] Make Maniphest custom fields extend PhabricatorCustomField Summary: Ref T418. These implementations share no method names, so we can safely just move Maniphest fields into the `PhabricatorCustomField` hierarchy. Replaces two Maniphest-specific custom field exceptions which nothing catches. Test Plan: Viewed Maniphest, edited/altered custom fields. Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T418 Differential Revision: https://secure.phabricator.com/D6927 --- src/__phutil_library_map__.php | 12 +++++++----- .../ManiphestAuxiliaryFieldDefaultSpecification.php | 8 ++++---- .../ManiphestAuxiliaryFieldSpecification.php | 1 + .../ManiphestAuxiliaryFieldTypeException.php | 8 -------- .../ManiphestAuxiliaryFieldValidationException.php | 8 -------- .../maniphest/field/ManiphestCustomField.php | 6 ++++++ 6 files changed, 18 insertions(+), 25 deletions(-) delete mode 100644 src/applications/maniphest/auxiliaryfield/ManiphestAuxiliaryFieldTypeException.php delete mode 100644 src/applications/maniphest/auxiliaryfield/ManiphestAuxiliaryFieldValidationException.php create mode 100644 src/applications/maniphest/field/ManiphestCustomField.php diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 70c6a55953..350a18b7da 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -686,12 +686,11 @@ phutil_register_library_map(array( 'ManiphestAction' => 'applications/maniphest/constants/ManiphestAction.php', 'ManiphestAuxiliaryFieldDefaultSpecification' => 'applications/maniphest/auxiliaryfield/ManiphestAuxiliaryFieldDefaultSpecification.php', 'ManiphestAuxiliaryFieldSpecification' => 'applications/maniphest/auxiliaryfield/ManiphestAuxiliaryFieldSpecification.php', - 'ManiphestAuxiliaryFieldTypeException' => 'applications/maniphest/auxiliaryfield/ManiphestAuxiliaryFieldTypeException.php', - 'ManiphestAuxiliaryFieldValidationException' => 'applications/maniphest/auxiliaryfield/ManiphestAuxiliaryFieldValidationException.php', 'ManiphestBatchEditController' => 'applications/maniphest/controller/ManiphestBatchEditController.php', 'ManiphestConstants' => 'applications/maniphest/constants/ManiphestConstants.php', 'ManiphestController' => 'applications/maniphest/controller/ManiphestController.php', 'ManiphestCreateMailReceiver' => 'applications/maniphest/mail/ManiphestCreateMailReceiver.php', + 'ManiphestCustomField' => 'applications/maniphest/field/ManiphestCustomField.php', 'ManiphestDAO' => 'applications/maniphest/storage/ManiphestDAO.php', 'ManiphestDefaultTaskExtensions' => 'applications/maniphest/extensions/ManiphestDefaultTaskExtensions.php', 'ManiphestEdgeEventListener' => 'applications/maniphest/event/ManiphestEdgeEventListener.php', @@ -2746,12 +2745,15 @@ phutil_register_library_map(array( 'LiskRawMigrationIterator' => 'PhutilBufferedIterator', 'ManiphestAction' => 'ManiphestConstants', 'ManiphestAuxiliaryFieldDefaultSpecification' => 'ManiphestAuxiliaryFieldSpecification', - 'ManiphestAuxiliaryFieldSpecification' => 'PhabricatorMarkupInterface', - 'ManiphestAuxiliaryFieldTypeException' => 'Exception', - 'ManiphestAuxiliaryFieldValidationException' => 'Exception', + 'ManiphestAuxiliaryFieldSpecification' => + array( + 0 => 'ManiphestCustomField', + 1 => 'PhabricatorMarkupInterface', + ), 'ManiphestBatchEditController' => 'ManiphestController', 'ManiphestController' => 'PhabricatorController', 'ManiphestCreateMailReceiver' => 'PhabricatorMailReceiver', + 'ManiphestCustomField' => 'PhabricatorCustomField', 'ManiphestDAO' => 'PhabricatorLiskDAO', 'ManiphestDefaultTaskExtensions' => 'ManiphestTaskExtensions', 'ManiphestEdgeEventListener' => 'PhutilEventListener', diff --git a/src/applications/maniphest/auxiliaryfield/ManiphestAuxiliaryFieldDefaultSpecification.php b/src/applications/maniphest/auxiliaryfield/ManiphestAuxiliaryFieldDefaultSpecification.php index b0bf8bc179..8a2ef852e9 100644 --- a/src/applications/maniphest/auxiliaryfield/ManiphestAuxiliaryFieldDefaultSpecification.php +++ b/src/applications/maniphest/auxiliaryfield/ManiphestAuxiliaryFieldDefaultSpecification.php @@ -121,7 +121,7 @@ class ManiphestAuxiliaryFieldDefaultSpecification break; default: $label = $this->getLabel(); - throw new ManiphestAuxiliaryFieldTypeException( + throw new Exception( "Field type '{$type}' is not a valid type (for field '{$label}')."); break; } @@ -248,7 +248,7 @@ class ManiphestAuxiliaryFieldDefaultSpecification switch ($this->getFieldType()) { case self::TYPE_INT: if ($this->getValue() && !is_numeric($this->getValue())) { - throw new ManiphestAuxiliaryFieldValidationException( + throw new PhabricatorCustomFieldValidationException( pht( '%s must be an integer value.', $this->getLabel())); @@ -262,7 +262,7 @@ class ManiphestAuxiliaryFieldDefaultSpecification return true; case self::TYPE_DATE: if ((int)$this->getValue() <= 0 && $this->isRequired()) { - throw new ManiphestAuxiliaryFieldValidationException( + throw new PhabricatorCustomFieldValidationException( pht( '%s must be a valid date.', $this->getLabel())); @@ -271,7 +271,7 @@ class ManiphestAuxiliaryFieldDefaultSpecification case self::TYPE_USER: case self::TYPE_USERS: if (!is_array($this->getValue())) { - throw new ManiphestAuxiliaryFieldValidationException( + throw new PhabricatorCustomFieldValidationException( pht( '%s is not a valid list of user PHIDs.', $this->getLabel())); diff --git a/src/applications/maniphest/auxiliaryfield/ManiphestAuxiliaryFieldSpecification.php b/src/applications/maniphest/auxiliaryfield/ManiphestAuxiliaryFieldSpecification.php index 7cc76ea8e5..afcbe1e2e6 100644 --- a/src/applications/maniphest/auxiliaryfield/ManiphestAuxiliaryFieldSpecification.php +++ b/src/applications/maniphest/auxiliaryfield/ManiphestAuxiliaryFieldSpecification.php @@ -4,6 +4,7 @@ * @group maniphest */ abstract class ManiphestAuxiliaryFieldSpecification + extends ManiphestCustomField implements PhabricatorMarkupInterface { const RENDER_TARGET_HTML = 'html'; diff --git a/src/applications/maniphest/auxiliaryfield/ManiphestAuxiliaryFieldTypeException.php b/src/applications/maniphest/auxiliaryfield/ManiphestAuxiliaryFieldTypeException.php deleted file mode 100644 index 913ddc494e..0000000000 --- a/src/applications/maniphest/auxiliaryfield/ManiphestAuxiliaryFieldTypeException.php +++ /dev/null @@ -1,8 +0,0 @@ -