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

NEW Add extension point to DataObject->hydrate() #10047

Merged
merged 1 commit into from Aug 26, 2021

Conversation

madmatt
Copy link
Member

@madmatt madmatt commented Aug 8, 2021

This PR creates a new extension point in DataObject->hydrate(). For reference, hydrate() is called on every newly created DataObject when data is retrieved from the database (e.g. during iteration of a DataList or similar).

This extension allows you to override hydrated columns, or pre-fetch some lazy-loaded ones. In my case, I am upgrading the madmatt/silverstripe-encrypt-at-rest module to CMS4 and needed a way to inject into the hydration process (as CMS3 hydrated with DBField objects but CMS4 just hydrates plain old scalar values - which in my case is an encrypted string).

Copy link
Member

@emteknetnz emteknetnz left a comment

Choose a reason for hiding this comment

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

Approach seems fine. Would you be able to write a unit test for this?

@madmatt
Copy link
Member Author

madmatt commented Aug 25, 2021

Hey @emteknetnz , I've added a test to DataObjectTest and confirmed that phpunit has passed that new test as well as all other tests on DataObjectTest. It appears that other PRs are failing on similar tests to what this one is, so I presume these are just broken tests that need to be fixed separately.

Copy link
Member

@emteknetnz emteknetnz left a comment

Choose a reason for hiding this comment

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

Looks great. Travis failures are unrelated

@emteknetnz emteknetnz merged commit b5c3b60 into silverstripe:4 Aug 26, 2021
@madmatt madmatt deleted the pulls/extend-hydrate branch September 3, 2021 05:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants