Skip to content

Conversation

@mjauvin
Copy link
Member

@mjauvin mjauvin commented Mar 14, 2022

This change allows a plugin to handle the model.afterFetch event AFTER the Model handler.

The current code uses the afterFetch() method which always runs AFTER any event handler.

ref. https://github.com/wintercms/storm/blob/develop/src/Database/Model.php#L162-L168

The alternative would be to modify the code referenced above in the base Database/Model, but that could lead to breakage in backward compatibility.

@mjauvin mjauvin added the enhancement PRs that implement a new feature or substantial change label Mar 14, 2022
@mjauvin mjauvin requested a review from LukeTowers March 14, 2022 21:10
@mjauvin mjauvin self-assigned this Mar 14, 2022
@mjauvin mjauvin changed the title comvert afterFetch method to an event handler for model.afterFetch Convert afterFetch() method to an event handler for model.afterFetch Mar 14, 2022
@damsfx
Copy link
Contributor

damsfx commented Mar 15, 2022

My test did not work.

Steps to reproduce :

  • New installation of WinterCMS
  • Edit the Demo theme to include a field
form:
   fields:
       header_images:
           label: Header images
           span: left
           type: fileupload
           mode: image
           imageWidth: 200
           imageHeight: 200

When going to theme settings, an error occurs :

Model 'Cms\Models\ThemeData' does not contain a definition for 'header_images'.

@mjauvin
Copy link
Member Author

mjauvin commented Mar 15, 2022

Closed in favor of #495

@mjauvin mjauvin closed this Mar 15, 2022
@mjauvin mjauvin deleted the afterfetch-event-handler branch March 15, 2022 03:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement PRs that implement a new feature or substantial change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants