Extensible bake - markstory/cakephp GitHub Wiki
Bake comes with several built in tasks. While these tasks are quite handy userland plugins or applications might want to include other generator tasks.
When bake is starting, it could scan the application and all plugins for suitable tasks and include them as subtasks of BakeShell.
Finding suitable tasks
For each installed plugin the Bake could scan the Console/Command/Task/
directory for any tasks that extend BakeTask
. Matching classes would be collected and added to BakeShell's Task list. The scanning order would be:
- CakePHP core
- Application
- Plugins
Since duplicates could be created if two plugins contain a task with the same name, duplicates will need to be ignored. For example, PluginA and PluginB both provide a ThingTask
. The task from PluginA would be used and PluginB's would be ignored. If a plugin or app task would duplicate a core task, they would replace and override the core task.
BakeTask interface
BakeTask would be made into an abstract class that will require the following features from its subclasses:
execute()
method must be implemented. This is needed to make the task a subcommand of bake.bake($name)
method must be implemented. This method is used for cross task method calls.
Tasks would also be expected to set the pathFragment
property. This fragment is used to generate paths in the App or Plugins.