-
-
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] Move daoName generation so we don't need to pass the variable name #18552
Conversation
(Standard links)
|
6b9110b
to
86da302
Compare
86da302
to
99d57de
Compare
@@ -1820,7 +1820,7 @@ public static function mergeLocations($mergeHandler) { | |||
if (!$otherBlockId) { | |||
continue; | |||
} | |||
$otherBlockDAO = $mergeHandler->copyDataToNewBlockDAO($daoName, $otherBlockId, $name, $blkCount); | |||
$otherBlockDAO = $mergeHandler->copyDataToNewBlockDAO($otherBlockId, $name, $blkCount); |
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.
Looks like line 1812 above (which defines the now-unused variable $daoName
) is no longer needed.
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.
@colemanw - yes - removing that in this PR makes it confllct with the one in the PR template
switch ($entity) { | ||
case 'email': | ||
return new CRM_Core_DAO_Email(); | ||
|
||
case 'address': | ||
return new CRM_Core_DAO_Address(); | ||
|
||
case 'phone': | ||
return new CRM_Core_DAO_Phone(); | ||
|
||
case 'website': | ||
return new CRM_Core_DAO_Website(); | ||
|
||
case 'im': | ||
return new CRM_Core_DAO_IM(); | ||
|
||
default: | ||
// Mostly here, along with the switch over a more concise format, to help IDEs understand the possibilities. | ||
throw new CRM_Core_Exception('Unsupported entity'); | ||
} |
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.
Hmm, I just removed a long switch
statement like this in #18546. Aside from the $entity
being the nonstandard lowercase, is there any reason not to do it this way?
switch ($entity) { | |
case 'email': | |
return new CRM_Core_DAO_Email(); | |
case 'address': | |
return new CRM_Core_DAO_Address(); | |
case 'phone': | |
return new CRM_Core_DAO_Phone(); | |
case 'website': | |
return new CRM_Core_DAO_Website(); | |
case 'im': | |
return new CRM_Core_DAO_IM(); | |
default: | |
// Mostly here, along with the switch over a more concise format, to help IDEs understand the possibilities. | |
throw new CRM_Core_Exception('Unsupported entity'); | |
} | |
return CRM_Core_DAO_AllCoreTables::getFullName(CRM_Core_DAO_AllCoreTables::convertEntityNameToCamel($entity, TRUE)); |
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.
@colemanw yeah - the follow on patches do more by adding extra variables in there
As an aside, I think a switch in it's own function is not bad for readability - it's the long switch in the midst of a function that is
Ok I'll trust you on this one. |
Overview
Minor code cleanup - rather than pass around the name of the dao class just figure it out from the entity name when needed. This has the added benefit that we can declare the class in a way IDEs recognise
Before
After
Technical Details
$name
is the name of the entity - I thought about renaming but in follow up patches I can remove most references to it so I've left for nowComments
Note that we can remove some variables now - I've excluded from this PR as they clash with #18500