-
-
Notifications
You must be signed in to change notification settings - Fork 824
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
Get phone_type by name. dev/core#2138 #18842
Conversation
(Standard links)
|
CRM/Core/BAO/Phone.php
Outdated
@@ -92,7 +92,8 @@ public static function allPhones($id, $updateBlankLocInfo = FALSE, $type = NULL, | |||
|
|||
$cond = NULL; | |||
if ($type) { | |||
$phoneTypeId = array_search($type, CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id')); | |||
$phoneTypes = CRM_Core_OptionGroup::values('phone_type', TRUE, FALSE, FALSE, NULL, 'name'); | |||
$phoneTypeId = CRM_Utils_Array::value($type, $phoneTypes); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what the latest standard is but I think it would be preferred to replace both these lines with $phoneTypeId = CRM_Core_PseudoConstant::getKey('CRM_Core_DAO_Phone', 'phone_type_id', $type)
. In any case CRM_Utils_Array::value
is discouraged in places where you can use $a[$b] ?? NULL
instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes -
$phoneTypeId = CRM_Core_PseudoConstant::getKey('CRM_Core_DAO_Phone', 'phone_type_id', $type);
is the preferred syntax for this
Thanks @demeritcowboy and @eileenmcnaughton . I have updated the code. |
|
Nice - thanks @muniodiego @demeritcowboy |
Overview
When wanting to send an SMS, a mobile phone is not identified if it is not primary and if the label of the mobile phone type has been translated or modifed.