Extensions - Setup <classloader> during "enable" and "uninstall" #20116
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
The builds on the theme of PR #20091. Recall from the previous PR that an extension might declare classloaders:
and then use them for installation:
This PR extends classloading support to other stages of the lifecycle:
For a more complete example, see https://gist.github.com/totten/4864a530b078c6ea86b52d7b578d7c16
Before
Some of these workflows fail:
cv en whizbang
cv en whizbang && cv dis whizbang && cv en whizbang
cv en whizbang && cv dis whizbang && cv ext:uninstall whizbang
cv en whizbang && cv ext:uninstall whizbang
After
All of these workflows pass:
cv en whizbang
cv en whizbang && cv dis whizbang && cv en whizbang
cv en whizbang && cv dis whizbang && cv ext:uninstall whizbang
cv en whizbang && cv ext:uninstall whizbang
Technical Details
Why is this necessary? Recall that (for a typical admin) the lifecycle of an extension is:
$x
$x
$x
$x
Step
#2
disables the classloader for purposes of regular page-loading. However, when you get to step#3a
or#3b
, then you need the classloader again. Of course, it would be premature to fully activate the extension (e.g. do not firehook_civicrm_config
on a disabled module). But you should have access to the classes.