-
-
Notifications
You must be signed in to change notification settings - Fork 825
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
[REF] Make apiv3-specific helper generally available. #17169
Conversation
(Standard links)
|
84c2ee0
to
2e5ce18
Compare
I'm not sure I agree with this as a "canon" function to include in At the very least I think the function is named incorrectly, as the current name suggests it is converting to something standard, which it is not. But I'm not convinced it belongs in |
@colemanw there are 27 calls to this function - a good portion of them are doing what the apiv4 call is doing - figuring out the likely alias for the id field (not such an apiv4 thing) & it was in order to re-use that that I thought to do this. Since this approach - https://github.com/civicrm/civicrm-core/pull/16983/files#diff-a2c7ae339db570d160a69bd288516d11R90 seems silly to me Moving this to deprecated utils seems clearly no worth doing so I would close in preference to that. |
@eileenmcnaughton could you pls clarify what you mean by "what the apiv4 call is doing"? civicrm-core/Civi/Api4/Generic/AbstractEntity.php Lines 70 to 72 in c2adedc
And that's only because, as the comment says, it's to honor a legacy hook contract. |
@colemanw it's taking 'activity' or 'OptionGroup' and figuring out that the alias is 'activity_id' .... |
@eileenmcnaughton once again I find myself in need of a function like this. This time to automatically generate a table alias for a join (converting e.g. I think my only complaint about this pr is the placement of the function. Since |
@colemanw I'm OK with String - although it is a string-munging that is logically specific to our DAO strings... |
Yea if you look at |
More grist for the mill:
Disclaimer/data-point: I've only skimmed and haven't fully wrapped my head around the concept of this mapping. Maybe there's a more distinctive name. For me, the phrase "entity name" evokes the UpperCamel formulation, as it in appears |
@eileenmcnaughton I've made the change and rebased this. |
CRM/Utils/String.php
Outdated
* | ||
* @return string | ||
*/ | ||
public static function convertNameToLowerCase(string $entity): string { |
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 think it needs to have the word Entity in the name since it's a special sort of name being converted
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 kinda prefer to put it in AllCoreTables but I can live with here)
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.
Ok I changed the name.
This function should only be called from apiv3 but it's prevalence suggests it's more generally useful. I have only done a couple of sample switches to use it. I think the apiv4 one could in theory result in an error as is since there is no require_once for the utils.php file
)), '_'); | ||
if (!$entity) { | ||
// @todo - this should not be called when empty. | ||
return ''; |
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.
ideally add deprecation noise if this is hit
@eileenmcnaughton I've taken your suggestion to move it to |
Overview
Internal code cleanup - Make apiv3-specific helper generally available.
Before
No alternative to the discourages
_civicrm_api_get_entity_name_from_camel
After
Recommended alternative
CRM_Core_DAO::getEntityNameFromCamelName
Technical Details
This function should only be called from apiv3 but it's prevalence suggests it's more
generally useful. I have only done a couple of sample switches to use it. I think the
apiv4 one could in theory result in an error as is since there is no require_once for the
utils.php file
Comments
Once merged we ca switch across other calls & more noisily deprecate the function