Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
Add support for custom presets #370
Comments
|
|
|
So, I've done some work on this request, but I want to make sure my implementation wasn't going to rock the boat too much before I go any further. I'm proposing a change to how the Configuration object holds and validates the preset option. Since all preset should implement the Preset Interface, I think the OptionsResolver should check the preset value using a closure to determine if the 'preset' option is the name of a class implementing the interface. This also means that the PRESET const in the Configuration could go away since it would no longer need to know the package maintained presets. It would be up to the ConfigurationResolver to map the package's presets from just a name to classes. Thoughts? |
|
@Andrew-Shook, hmm, I don't mind changing stuff there at all. However I am not sure I totally follow how this would work then. Right now if you supply no preset, it will run the guess in the config resolver. All of the predefined presets have a method for determine if they should be activated. If we remove the presets constants, how would the config resolver know which presets to check this method on? |
Right now we can create custom configuration based on presets, however I think it would be worth allowing custom presets also.
This would mean opening up the
Presetinterface so for example a framework could maintain their own Preset file and users can then use the preset, just by pointing their preset configuration to the class.Implementation
Configuration::resolveConfig, theOptionsResolvernow has to allowpresetto also be a valid class.ConfigResolver::resolve, add a new private methodresolvePreset, which has the current logic for resolving a preset, but also adds support for the preset variable could be a class fqn.ConfigResolverTestfor setting preset from a classPresetinterfaceComposerclassshouldBeAppliedandgetNamefromPresetinterface and add it to a new internal interface, which our presets implements. (this method is used for guessing the preset from composer, but does not make sense with custom preset as their are not registered in our application.)Usage
Using this should be rather straight forward, creating a custom Preset should be like this
And our config file would then look like