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) »
  • What do we do about Constant api in v3
Pages: [1]

Author Topic: What do we do about Constant api in v3  (Read 1509 times)

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
What do we do about Constant api in v3
March 14, 2011, 01:36:44 pm
At the moment Constant API isn't working in v3 we can either get it working or ditch it

I'm not 100% sure what it does that

civicrm_api('OptionValue','Get',$params);

doesn't do.

Likewise ActivityType API seems to be duplicated by both Option_Value_Get and by the Constant api (I think we have agreed to remove this one)

I feel that with Option_Value_Get over half the time people would know the option_group_name & need to get the option_group_id so I think it would be good to think about accepting option_group_name as a parameter for it (& think about how that would look)
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

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: What do we do about Constant api in v3
March 14, 2011, 03:04:49 pm
Quote from: Eileen on March 14, 2011, 01:36:44 pm
I feel that with Option_Value_Get over half the time people would know the option_group_name & need to get the option_group_id so I think it would be good to think about accepting option_group_name as a parameter for it (& think about how that would look)

civicrm_api('OptionValue','Get', array(option_group_name =''activity_type"));

This being said, we can keep a simple wrapper

civicrm_api3_activity_type_get ($params) {
  return civicrm_api('OptionValue','Get', array(option_group_id = 2));
}

No idea what constant does
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: What do we do about Constant api in v3
March 14, 2011, 03:08:35 pm
civicrm_api3_activity_type_get ($params) {

activity_type is one of many so I don't think it should have it's own wrapper

At the moment I expect you can't pass option_group_name to option_value_get? I'm assuming it only accepts option_group_id?
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

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: What do we do about Constant api in v3
March 14, 2011, 11:51:30 pm
Quote from: Eileen on March 14, 2011, 03:08:35 pm
At the moment I expect you can't pass option_group_name to option_value_get? I'm assuming it only accepts option_group_id?

Indeed.

As for the wrapper vs. not wrapper, the issue is that you are exposing how stuff are being implemented. ie if tomorrow ActivityType gets a hierarchy or ACL, it will likely move to its own table. Shouldn't be a concern for the calling party of the API.

What about having a generic wrapper for options?

The issue will be to document, have to have a look at your generate function.

Or may be we keep that option for the next release and focus on finish what's on the table...

X+
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: What do we do about Constant api in v3
March 15, 2011, 12:02:51 am
The reason I'm keen on it is I feel like we should dump activity_type api & if we leave it much later we won't be able to remove it from v3.

I did generate OptionGroup & OptionValue examples but I think the tests failed so not the best examples...
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

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: What do we do about Constant api in v3
March 15, 2011, 12:14:36 am
Ok, let's take it out, if we re-introduce it, that will be in a generic manner.

Still don't know what constant does ;)

X+
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: What do we do about Constant api in v3
March 15, 2011, 12:17:56 am
Well, perhaps we should remove Constant api & re-introduce it if it has a 'sponsor'.

That one & the 2 relationship api (and the missing location apis) are the only ones with any major remaining issues

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

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: What do we do about Constant api in v3
March 15, 2011, 03:05:09 pm
Hi,

Looked, some (eg list of countries) are not in the OptionValues. I fixed so the param is a single array, tested on civicrm/ajax/doc.

I fixed some of the tests. Some others will never work, eg:

Code: [Select]
        $parameters = array( true, false, true );
        $result = civicrm_api3_constant_get( 'activityType', $parameters );

I'm not familiar enough with the morse code to know what that param means, but it won't fit into api v3.

I'd suggest to say that Constant get in v3 only works with name= 'TheTypeOfPseudoConstant' as the only accepted param), the extra param are going to come back as soon as someone figure out what it's supposed to mean, translate that into a human readable associative array, submit a patch and a test suite. but after v3.

If ok, I suppress the tests with the extra params.


Constant solved!


-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: What do we do about Constant api in v3
March 15, 2011, 03:35:37 pm
OK sounds good. Just add the verify mandatory in so that it passes the API Standards.

ActivityType, however, is redundant?
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

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: What do we do about Constant api in v3
March 15, 2011, 03:39:28 pm
Was already done. Or do you mean adding a test ?

Code: [Select]
function civicrm_api3_constant_get($params = array())
{
  _civicrm_api3_initialize(true);
  try{
    civicrm_api3_verify_mandatory ($params,null,array ('name'));
    $name= $params ['name'];

Kill ActivityType, I know you want it ;)
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: What do we do about Constant api in v3
March 15, 2011, 03:42:55 pm
Erm -

function civicrm_api3_constant_get($params = array())


I don't think there should be a default argument?
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

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: What do we do about Constant api in v3
March 15, 2011, 04:17:06 pm
I fixed the tests
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

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: What do we do about Constant api in v3
March 16, 2011, 12:11:30 am
Quote from: Eileen on March 15, 2011, 03:42:55 pm
I don't think there should be a default argument?

Erm,

Me neither.

X+
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • What do we do about Constant api in v3

This forum was archived on 2017-11-26.