CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Rescuing GET - step 1
Pages: [1]

Author Topic: Rescuing GET - step 1  (Read 671 times)

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Rescuing GET - step 1
September 21, 2010, 06:45:37 pm
How about this for a first step towards bring the 'GET' vs Search back to the API - this is just on the Event API but basically it says that if you pass in $params['version'] then it will act like a search rather than give you an error on multiple matches (per THE PLAN). I was going to do it on a > than but it didn't seem to be casting correctly & then I realised just getting people to pass in a version was enough to merit this behaviour.

If we apply something like this to all the gets that 'don't work' at least we can declare 'search' deprecated & push people to start using 'get' & to start passing in a version



Code: [Select]
Index: api/v2/Event.php
===================================================================
--- api/v2/Event.php    (revision 29629)
+++ api/v2/Event.php    (working copy)
@@ -80,7 +80,7 @@
     
     require_once 'CRM/Event/BAO/Event.php';
     $eventBAO = CRM_Event_BAO_Event::create($params, $ids);
-   
+
     if ( is_a( $eventBAO, 'CRM_Core_Error' ) ) {
         return civicrm_create_error( "Event is not created" );
     } else {
@@ -97,9 +97,8 @@
 /**
  * Get an Event.
  *
- * This api is used to retrieve all data for an existing Event.
- * Required parameters : id of event
- *
+ * This api is used to retrieve all data for existing Events.
+ *  *
  * @param  array $params  an associative array of title/value property values of civicrm_event
  *
  * @return  If successful array of event data; otherwise object of CRM_Core_Error.
@@ -119,7 +118,7 @@
     
     $event  =& civicrm_event_search( $params );
     
-    if ( count( $event ) != 1 &&
+    if ( count( $event ) != 1 && !$params['version'] &&
          ! CRM_Utils_Array::value( 'returnFirst', $params ) ) {
         return civicrm_create_error( ts( '%1 events matching input params', array( 1 => count( $event ) ) ) );
     }
@@ -135,7 +134,7 @@
 /**
  * Get Event record.
  *
- *
+ * @deprecated deprecated since version 3.3.4 - Use GET
  * @param  array  $params     an associative array of name/value property values of civicrm_event
  *
  * @return  Array of all found event property values.
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Rescuing GET - step 1

This forum was archived on 2017-11-26.