Extensions - mpaleo/scaffolder GitHub Wiki
Compilation pipeline
1. Model compiler (compile > run extensions) *
2. Controller compiler (compile > run extensions) *
3. Migration compiler (compile > run extensions) *
4. Index view compiler (compile > run theme extension > run extensions) *
5. Create view compiler (compile > run theme extension > run extensions) *
6. Edit view compiler (compile > run theme extension > run extensions) *
7. Page layout compiler (compile > run theme extension > run extensions)
8. Create layout compiler (compile > run theme extension > run extensions)
9. Edit layout compiler (compile > run theme extension > run extensions)
10. Dashboard view compiler (compile > run theme extension > run extensions)
11. Welcome view compiler (compile > run theme extension > run extensions)
12. Login view compiler (compile > run theme extension > run extensions)
# For each model = *
Theme extension
mpaleo/scaffolder-theme-material already provides the basis to implement extensions. By default it returns the compiled stub as is, but you can hook up there and make the changes you want.
Let's change the text "Starter material template" from the welcome view to "Theme extension working!"
public function runAfterWelcomeViewIsCompiled($compiledStub, $scaffolderConfig)
{
return str_replace('Starter material template', 'Extension working!', $compiledStub);
}
You could also add more functionalities to the generator using views. The theme must tag the extension views using the scaffolder.theme.extension tag. For instance, you can add more fields to the scaffolderConfig, and use them in the desired extension.
Requirements:
- The theme extension must implement
Scaffolder\Support\Contracts\ScaffolderThemeExtensionInterface - (Optional) The view or views must be tagged with
scaffolder.theme.extension
Extensions
Besides of the theme extensions, you can use extensions that are not necessarily related to theme implementations. These extensions works in the same way as the theme extensions, but have a little more of flexibility.
Requirements:
- The extension must implement
Scaffolder\Support\Contracts\ScaffolderExtensionInterface - The instance must be tagged with
scaffolder.extension - (Optional) The view or views must be tagged with
scaffolder.extension
Important
Be careful to not screw up in the extension implementation, because is the last step in the compile pipeline, and the content returned by the extension, is what the compiler stores.