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.
Description
Managing the plugin definition can be very time-consuming.
If you want to create (for example) a snippet, you also have to declare it in the index.php file.
This PR allows you, to leave the definition blank. It gets everything from the folders:
Kirby::plugin('your/plugin')
Summary of changes
Adding 3 new methods to Kirby\Cms\Plugin:
loadTranslations
: Generate definition of translation folder (I18n). Encoding json or/and adding prefix to keysloadFiles
: Generates the definition of a specific folder.autoload
: Generates the definition of a specific folder (or folder array).Reasoning
Many developers have already developed their own workaraound for this. It is time to implement something standardised.
Additional context
NOTICE!
Kirby::plugin('your/plugin');
gets the registered plugin and null if not registered before.Now it's sets the extends. Please check for possible incompatibility.
Changelog
Fixes
Breaking changes
Docs
This example loads following items (based of the existing folders from the current plugin folder):
snippets
,templates
,blueprint
config
folder and import the files (To outsource the plugin definition)I18n
folder. Converts JSON files (if needed) and adding prefix to the keys based by the plugin nameReady?
For review team