Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CRM-20410 Reformat CRM_SMS_BAO_Provider to use standard create function style rather than the split #10135

Merged
merged 5 commits into from
Apr 11, 2017

Conversation

seamuslee001
Copy link
Contributor

@seamuslee001 seamuslee001 commented Apr 11, 2017

$dao->save();
}
public static function create($params, $ids = array()) {
$id = CRM_Utils_Array::value('id', $ids, CRM_Utils_Array::value('id', $params));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the $ids array is legacy - just use params for an new fn

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems like as per https://github.com/civicrm/civicrm-core/blob/master/api/v3/utils.php#L1281 it expects a 2nd param which is ids

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it handles rather than expects $ids

@@ -64,12 +64,12 @@ public function testCreateAndUpdateProvider() {
'is_active' => 1,
'api_type' => 1,
);
CRM_SMS_BAO_Provider::saveRecord($values);
CRM_SMS_BAO_Provider::create($values, array());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tend to think it only matters to test the api - the BAO is tested in the process & the api is the recommended way to call it. BAO can change, but api is the one we commit to

$provider->id = $id;
$provider->find(TRUE);
}
if ($id) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so, in theory all of this could be in the extension & be removed from here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

up to L116 but yes agree with that if needed

}
elseif ($this->_action & CRM_Core_Action::ADD) {
CRM_SMS_BAO_Provider::saveRecord($recData);
if ($this->_action && (CRM_Core_Action::UPDATE || CRM_Core_Action::ADD)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$ids is not required - set $params['id'] instead

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it not? it seems like it is needed as per basic_create function

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no - only $params is needed - $ids is being phased out

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(maybe you should comment whereever you got that from...)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

else {
$ids = array();
}
CRM_SMS_BAO_Provider::create($recData, $ids);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

call api not bao

@eileenmcnaughton
Copy link
Contributor

@seamuslee001 this looks good - only question is whether we should put the domain part in an extension. I'm trying to decide if putting in the extension instead of here will make it easier later or it's a 'might as well merge & when @nganivet does his big change it can be adjusted then....

@nganivet
Copy link
Contributor

I would say merge ... I always dream I can do so many things, but the hash reality of customer commitments kicks in and I have to postpone. Might be a while before I have time for this big refactor, although it's nice to see these pieces fall in place.

@eileenmcnaughton
Copy link
Contributor

Well at least @seamuslee001 effort adding an api will make it easier

@seamuslee001
Copy link
Contributor Author

Jenkins re test this please

1 similar comment
@seamuslee001
Copy link
Contributor Author

Jenkins re test this please

@eileenmcnaughton
Copy link
Contributor

Oh - I thought we'd merged this when I blamed it for breakage :-)

@eileenmcnaughton
Copy link
Contributor

test this please

@eileenmcnaughton eileenmcnaughton merged commit 5ce0c89 into civicrm:master Apr 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants