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) »
  • objectRef as array or object in civicrm_post and _pre hooks
Pages: [1]

Author Topic: objectRef as array or object in civicrm_post and _pre hooks  (Read 708 times)

Erik Hommel

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1773
  • Karma: 59
    • EE-atWork
  • CiviCRM version: all sorts
  • CMS version: Drupal
  • MySQL version: Ubuntu's latest LTS version
  • PHP version: Ubuntu's latest LTS version
objectRef as array or object in civicrm_post and _pre hooks
May 23, 2013, 10:55:03 am
At the moment the $objectRef in the civicrm_pre hook and the civicrm_post hook is sometimes an object and sometimes an array. I assume we do not really want this inconsistency, it is just something that crept in from the BAO's? What is the preference, object or array? Is it worth raising an issue for and putting it on the list for a sprint?
Consultant/project manager at EEatWork and CiviCooP (http://www.civicoop.org/)

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: objectRef as array or object in civicrm_post and _pre hooks
May 23, 2013, 11:25:17 am
Erik- I thought it was an array PRE, an object POST & anything else was a bug.

 I'm pretty sure we sorted out address, don't know how to deal with ones line 'entity_tag' & group_contact' - which do multiples if they do anything & any others are not on my radar. I would suggest you could log a ticket (or do a PR) against 4.4 for any individual ones you come across (& document on the wiki somewhere.

I don't know how big the problem is? My sense was that it was not too many now?
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

Erich Schulz

  • I post frequently
  • ***
  • Posts: 142
  • Karma: 5
    • When no-one understands what you are going on about its time to start a blog
  • CiviCRM version: 4.4
  • CMS version: Drupal 7
  • MySQL version: 5.somthing
  • PHP version: 5.3.3
Re: objectRef as array or object in civicrm_post and _pre hooks
May 24, 2013, 07:33:48 pm
remember reading a long post in drupal about this... and seemed unresolved

Eileen is there a reason for that convention? (just a one word response is enough - just curious)

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: objectRef as array or object in civicrm_post and _pre hooks
May 25, 2013, 08:05:46 am

historic reason:

most bao objects get arrays as their parameters for the object values. You send this array to a "pre" hook which can potentially modify what values get to the object and/or modify the create behavior of the function. hence an array is sent for the pre hook

for the post hook, the object is already created :)

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • objectRef as array or object in civicrm_post and _pre hooks

This forum was archived on 2017-11-26.