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

[WIP] Add pseudo-entity APIv4 Attachment #20494

Closed
wants to merge 5 commits into from

Conversation

monishdeb
Copy link
Member

@monishdeb monishdeb commented Jun 3, 2021

Overview

A brief description of the pull request. Keep technical jargon to a minimum. Hyperlink relevant discussions.

Before

What is the old user-interface or technical-contract (as appropriate)?
For optimal clarity, include a concrete example such as a screenshot, GIF (LICEcap, SilentCast), or code-snippet.

After

What changed? What is new old user-interface or technical-contract?
For optimal clarity, include a concrete example such as a screenshot, GIF (LICEcap, SilentCast), or code-snippet.

[WIP] Technical Details

Declare APIv4 Attachment abstract entity:

  • Created CRM_Core_BAO_Attachment which extends CRM_Core_DAO
  • Moved all the utility functions from API3 Attachment to BAO fns. Idea is to use the common BAO fns for both APIv3 and APIv4
  • declared the CRM_Core_BAO_Attachment::fields which got a combinations of civicrm_file and civicrm_entity_file fields
  • all the five pseudo fields (name, field_name, url, path and content) are declared via a separate function CRM_Core_BAO_Attachment::pseudoFields
  • Manually return the BAO name for Attachment entity in _civicrm_api3_get_DAO and Civi/Api4/Utils/CoreUtil:: getBAOFromApiName
  • Construct the derived table for Attachment entity here Civi/Api4/Utils/CoreUtil::getTableName here
  • Add FieldSpec attribute pseudo and setter function (based on this attribute the non-DB fields could be excluded from query)

Api4 Attachment.create/update implementation

...

Api4 Attachment.get implementation

...

Api4 Attachment.delete implementation

...

Comments

Anything else you would like the reviewer to note

@civibot civibot bot added the master label Jun 3, 2021
@civibot
Copy link

civibot bot commented Jun 3, 2021

(Standard links)

Comment on lines 25 to 27
*
* @see https://docs.civicrm.org/user/en/latest/organising-your-data/contacts/
* @searchable primary
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
*
* @see https://docs.civicrm.org/user/en/latest/organising-your-data/contacts/
* @searchable primary
*

@colemanw
Copy link
Member

colemanw commented Jun 4, 2021

I think the attachment "Get" action might end up being an interesting blend of DAOGetAction and ArrayQueryActionTrait to allow filtering on both real and calculated fields.

@monishdeb monishdeb force-pushed the add_attachment_api4 branch 9 times, most recently from f3db703 to efa9296 Compare June 8, 2021 03:42
@monishdeb monishdeb force-pushed the add_attachment_api4 branch from b609a96 to 08b91c8 Compare June 9, 2021 17:41
@eileenmcnaughton
Copy link
Contributor

@totten @seamuslee001 this is the attachment WIP

On the contact image - I would be inclined to add handling in the attachment api for that field if possible - so it's invisible to api consumers that it is non-standard. I feel like that might pave the way to get calling code switched over and to 'at some point' change the table structure.

@demeritcowboy
Copy link
Contributor

This has conflicts and has been unworked on for several months. Going to close but feel free to reopen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants