From 6e62b28c53f60b4ccf4f512c3816ade8b8f15f24 Mon Sep 17 00:00:00 2001 From: Tim Mallezie Date: Tue, 17 Mar 2015 08:22:48 +0100 Subject: [PATCH] remove crm_util_api class v1 --- CRM/Activity/Form/Activity.php | 7 ++ CRM/Admin/Form/ParticipantStatusType.php | 8 +++ CRM/Admin/Form/Tag.php | 7 ++ CRM/Campaign/Form/Campaign.php | 7 ++ CRM/Campaign/Form/Survey/Main.php | 7 ++ CRM/Contact/Form/Contact.php | 7 ++ CRM/Contact/Form/Search.php | 7 ++ CRM/Contribute/Form/ContributionPage.php | 7 ++ CRM/Core/Form.php | 15 +++-- CRM/Event/Form/ManageEvent.php | 6 +- CRM/Event/Form/Participant.php | 7 ++ CRM/Event/Form/SearchEvent.php | 7 ++ CRM/Grant/Form/Grant.php | 7 ++ CRM/Member/Form/MembershipConfig.php | 7 ++ CRM/Profile/Form.php | 7 ++ CRM/Utils/Api.php | 84 ------------------------ 16 files changed, 105 insertions(+), 92 deletions(-) delete mode 100644 CRM/Utils/Api.php diff --git a/CRM/Activity/Form/Activity.php b/CRM/Activity/Form/Activity.php index facd92491d..ab9e242a08 100644 --- a/CRM/Activity/Form/Activity.php +++ b/CRM/Activity/Form/Activity.php @@ -121,6 +121,13 @@ class CRM_Activity_Form_Activity extends CRM_Contact_Form_Task { protected $_values = array(); protected $unsavedWarn = TRUE; + + /** + * Explicitly declare the entity api name. + */ + public function getDefaultEntity() { + return 'Activity'; + } /** * The _fields var can be used by sub class to set/unset/edit the diff --git a/CRM/Admin/Form/ParticipantStatusType.php b/CRM/Admin/Form/ParticipantStatusType.php index 3eff6f3f37..b7f5bfcbe0 100644 --- a/CRM/Admin/Form/ParticipantStatusType.php +++ b/CRM/Admin/Form/ParticipantStatusType.php @@ -33,6 +33,14 @@ * */ class CRM_Admin_Form_ParticipantStatusType extends CRM_Admin_Form { + + /** + * Explicitly declare the entity api name. + */ + public function getDefaultEntity() { + return 'ParticipantStatusType'; + } + public function buildQuickForm() { parent::buildQuickForm(); diff --git a/CRM/Admin/Form/Tag.php b/CRM/Admin/Form/Tag.php index 0859b03cca..10292215fe 100644 --- a/CRM/Admin/Form/Tag.php +++ b/CRM/Admin/Form/Tag.php @@ -39,6 +39,13 @@ */ class CRM_Admin_Form_Tag extends CRM_Admin_Form { protected $_isTagSet; + + /** + * Explicitly declare the entity api name. + */ + public function getDefaultEntity() { + return 'Tag'; + } /** * Build the form object. diff --git a/CRM/Campaign/Form/Campaign.php b/CRM/Campaign/Form/Campaign.php index c80c7b7b06..6686aa6e05 100644 --- a/CRM/Campaign/Form/Campaign.php +++ b/CRM/Campaign/Form/Campaign.php @@ -66,6 +66,13 @@ class CRM_Campaign_Form_Campaign extends CRM_Core_Form { * @var int */ protected $_campaignId; + + /** + * Explicitly declare the entity api name. + */ + public function getDefaultEntity() { + return 'Campaign'; + } public function preProcess() { if (!CRM_Campaign_BAO_Campaign::accessCampaign()) { diff --git a/CRM/Campaign/Form/Survey/Main.php b/CRM/Campaign/Form/Survey/Main.php index f17334b590..95b3165c2f 100644 --- a/CRM/Campaign/Form/Survey/Main.php +++ b/CRM/Campaign/Form/Survey/Main.php @@ -52,6 +52,13 @@ class CRM_Campaign_Form_Survey_Main extends CRM_Campaign_Form_Survey { * @var string */ protected $_context; + + /** + * Explicitly declare the entity api name. + */ + public function getDefaultEntity() { + return 'Survey'; + } public function preProcess() { parent::preProcess(); diff --git a/CRM/Contact/Form/Contact.php b/CRM/Contact/Form/Contact.php index d7c4aacab9..602b57bfcd 100644 --- a/CRM/Contact/Form/Contact.php +++ b/CRM/Contact/Form/Contact.php @@ -126,6 +126,13 @@ class CRM_Contact_Form_Contact extends CRM_Core_Form { * during the write phase */ public $_preEditValues; + + /** + * Explicitly declare the entity api name. + */ + public function getDefaultEntity() { + return 'Contact'; + } /** * Build all the data structures needed to build the form. diff --git a/CRM/Contact/Form/Search.php b/CRM/Contact/Form/Search.php index 94bc485517..76f3cb5ef1 100644 --- a/CRM/Contact/Form/Search.php +++ b/CRM/Contact/Form/Search.php @@ -159,6 +159,13 @@ class CRM_Contact_Form_Search extends CRM_Core_Form_Search { protected $_customSearchClass = NULL; protected $_openedPanes = array(); + + /** + * Explicitly declare the entity api name. + */ + public function getDefaultEntity() { + return 'Contact'; + } /** * Define the set of valid contexts that the search form operates on. diff --git a/CRM/Contribute/Form/ContributionPage.php b/CRM/Contribute/Form/ContributionPage.php index 8a2cb63446..19b8aa3013 100644 --- a/CRM/Contribute/Form/ContributionPage.php +++ b/CRM/Contribute/Form/ContributionPage.php @@ -81,6 +81,13 @@ class CRM_Contribute_Form_ContributionPage extends CRM_Core_Form { protected $_priceSetID = NULL; protected $_values; + + /** + * Explicitly declare the entity api name. + */ + public function getDefaultEntity() { + return 'Contribution'; + } /** * Set variables up before form is built. diff --git a/CRM/Core/Form.php b/CRM/Core/Form.php index 15810e6c0f..53078f0e5b 100644 --- a/CRM/Core/Form.php +++ b/CRM/Core/Form.php @@ -1037,6 +1037,14 @@ class CRM_Core_Form extends HTML_QuickForm_Page { $this->addDate($name . $to, ts('To:'), $required, array('formatType' => $dateFormat)); } } + + /** + * Classes extending CRM_Core_Form should implement this method. + * @throws Exception + */ + public function getDefaultEntity() { + throw new Exception("Cannot determine default entity. The form class should implement getDefaultEntity()."); + } /** * Adds a select based on field metadata. @@ -1058,12 +1066,7 @@ class CRM_Core_Form extends HTML_QuickForm_Page { */ public function addSelect($name, $props = array(), $required = FALSE) { if (!isset($props['entity'])) { - if (isset($this->entityName)) { - $props['entity'] = $this->entityName; - } - else { - $props['entity'] = CRM_Utils_Api::getEntityName($this); - } + $props['entity'] = $this->getDefaultEntity(); } if (!isset($props['field'])) { $props['field'] = strrpos($name, '[') ? rtrim(substr($name, 1 + strrpos($name, '[')), ']') : $name; diff --git a/CRM/Event/Form/ManageEvent.php b/CRM/Event/Form/ManageEvent.php index 74fb6b99db..188d165162 100644 --- a/CRM/Event/Form/ManageEvent.php +++ b/CRM/Event/Form/ManageEvent.php @@ -86,11 +86,13 @@ class CRM_Event_Form_ManageEvent extends CRM_Core_Form { * Check if repeating event. */ public $_isRepeatingEvent; - + /** * Explicitly declare the entity api name. */ - public $entityName = 'Event'; + public function getDefaultEntity() { + return 'Event'; + } /** * Set variables up before form is built. diff --git a/CRM/Event/Form/Participant.php b/CRM/Event/Form/Participant.php index 7b6a868fec..346046b099 100644 --- a/CRM/Event/Form/Participant.php +++ b/CRM/Event/Form/Participant.php @@ -188,6 +188,13 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment * @var null */ public $_onlinePendingContributionId = NULL; + + /** + * Explicitly declare the entity api name. + */ + public function getDefaultEntity() { + return 'Participant'; + } /** * Set variables up before form is built. diff --git a/CRM/Event/Form/SearchEvent.php b/CRM/Event/Form/SearchEvent.php index c9eab1c83c..865a923309 100644 --- a/CRM/Event/Form/SearchEvent.php +++ b/CRM/Event/Form/SearchEvent.php @@ -33,6 +33,13 @@ * */ class CRM_Event_Form_SearchEvent extends CRM_Core_Form { + + /** + * Explicitly declare the entity api name. + */ + public function getDefaultEntity() { + return 'Event'; + } /** * @return array diff --git a/CRM/Grant/Form/Grant.php b/CRM/Grant/Form/Grant.php index 7b36046e46..6b9aaae323 100644 --- a/CRM/Grant/Form/Grant.php +++ b/CRM/Grant/Form/Grant.php @@ -54,6 +54,13 @@ class CRM_Grant_Form_Grant extends CRM_Core_Form { protected $_contactID; protected $_context; + + /** + * Explicitly declare the entity api name. + */ + public function getDefaultEntity() { + return 'Grant'; + } /** * Set variables up before form is built. diff --git a/CRM/Member/Form/MembershipConfig.php b/CRM/Member/Form/MembershipConfig.php index 022a2a33e9..8598abfbb2 100644 --- a/CRM/Member/Form/MembershipConfig.php +++ b/CRM/Member/Form/MembershipConfig.php @@ -52,6 +52,13 @@ class CRM_Member_Form_MembershipConfig extends CRM_Core_Form { * @var string */ protected $_BAOName; + + /** + * Explicitly declare the entity api name. + */ + public function getDefaultEntity() { + return 'MembershipType'; + } public function preProcess() { $this->_id = $this->get('id'); diff --git a/CRM/Profile/Form.php b/CRM/Profile/Form.php index 31e24a1691..6bcf38ffbc 100644 --- a/CRM/Profile/Form.php +++ b/CRM/Profile/Form.php @@ -175,6 +175,13 @@ class CRM_Profile_Form extends CRM_Core_Form { protected $_currentUserID = NULL; protected $_session = NULL; + + /** + * Explicitly declare the entity api name. + */ + public function getDefaultEntity() { + return 'Profile'; + } /** * Pre processing work done here. diff --git a/CRM/Utils/Api.php b/CRM/Utils/Api.php deleted file mode 100644 index c2a1595060..0000000000 --- a/CRM/Utils/Api.php +++ /dev/null @@ -1,84 +0,0 @@ -