Skip to content

Multiple afters - #207

Open
efc wants to merge 4 commits into
statamic:4.xfrom
efc:multiple-afters
Open

efc wants to merge 4 commits into
statamic:4.xfrom
efc:multiple-afters

Conversation

@efc

@efc efc commented Aug 9, 2025

Copy link
Copy Markdown

This implements a method of allowing more than one after callback, as requested in #182.

It adds an option $id parameter to the SSG::after method that defaults to "unidentified". This means that all existing calls to SSG::after will work as they always have, overwriting one another. However, if one supplies an identifier string, then the callback function will be added to an array of callback functions instead of overwriting previous after callbacks.

One can also specify identifiers that should be skipped using the new SSG::skipAfter method. This allows you to explicitly prevent after callbacks from other parties from being run (for example, if you supply similar functionality yourself or you have found that their callback is incompatible with your use case).

Finally, it uses the identifiers to inform the user which after callbacks are being run or skipped.

Note the reversion in composer.json is probably not necessary, but was required to get the addon installed on my system.

@duncanmcclean

duncanmcclean commented Sep 22, 2025 •

Copy link
Copy Markdown
Member

One can also specify identifiers that should be skipped using the new SSG::skipAfter method.

Did you need this for your use case or did you add it just in case it is useful?

@efc

efc commented Sep 22, 2025

Copy link
Copy Markdown
Author

The skipAfter was needed because one vendor implemented an after that actually was different enough from mine to end up with a different result. So I found I needed a way to disable their after and use mine as a substitute. In this case, since they did not use an identifier, I was able to use skipAfter with the default unidentified id to disable their callback.

@duncanmcclean
duncanmcclean changed the base branch from master to 4.x January 28, 2026 16:33
@efc

efc commented Sep 29, 2026

Copy link
Copy Markdown
Author

Running into this one again.

I am using an addon that implements after but now I need to use after to copy some extra image directories. No way to do this as SSG is currently constructed.

I really wish that multiple after functions were possible. Is there anything I could do to move this along or have you decided it just is not worth it?

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.

2 participants