Simplify Command boilerplate for typical use-cases#218
Merged
totten merged 16 commits intocivicrm:masterfrom Sep 24, 2024
Merged
Simplify Command boilerplate for typical use-cases#218totten merged 16 commits intocivicrm:masterfrom
Command boilerplate for typical use-cases#218totten merged 16 commits intocivicrm:masterfrom
Conversation
Command pattern for typical use-casesCommand boilerplate for typical use-cases
…BaseApplication::configure() This is a semantic change to how BaseApplication is initialized. However, I don't believe anyone else is using this yet, so it's academic.
d01fa84 to
4cbdf55
Compare
It can be used in either inherited style or fluent style. And this symbol has not yet been published via cv-lib
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
This is a general shuffling the
Commandclass hierarchy. The basicCommandfromsymfony/consoleis the same, but several of the helpers used bycvcommands have been moved around.Most notably, the
BaseCommand(internal tocv-app) has been replaced by theCvCommand(which is now part ofcv-lib). The contract forCvCommandshould be easier to use, and -- when we get CiviCRM extension integration (#219) -- it should slot-in more easily.Before
The
BaseCommandclass is internal to cv-app. It is fairly heavy with helpers that don't need to be in there (low cohesion).Pretty much all commands require the use of
BootTrait. The boilerplate code involves importing the trait, activating the trait, and then figuring out where to call a few helper functions. This is done in every command-class.After
The
CvCommandclass is part of cv-lib, and it includesBootTrait.Some other helpers have been moved out to standalone utilities.
Common bootstrap options (
--level,--user) are declared inBaseApplication. Bootstrap behavior is automatically included by way ofCvCommand. The default behavior assumes that you want Civi to be booted before running the command. But this can be overridden viagetBootOptions().Comments
plugins.mdreferred to this part of the functionality as experimental. Plugin support was only recently merged. So... I don't think there's much of an install-base needing the old contracts ofBootTrait.--leveland--usershould still work, but they can't work the same. (TheCommandclass hasn't been loaded... so we have to start processing those flags before have theCommand.)