Needs review
Project:
Tourney
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
27 Apr 2012 at 21:52 UTC
Updated:
10 Sep 2012 at 19:53 UTC
Right now files need for a plugin a spread out in many directories that do not make sense and the process of creating a custom plugin is hard to understand.
We need to think from the plugin author perspective and create a simple, easy to understand structure that can be copied into a module and modified. This encourages learning and extending the system.
Comments
Comment #1
tom friedhof commentedThe BaseFormatControllers have been moved inside the plugins/tourney_formats directory. The plugins that ship with tourney module use one of these base format controllers as the controller of the plugin.
To create a new plugin, module developers need to create a $plugin definition like the following in their module:
Plugins should extend TourneyController to integrate with the Drupal entity system that saves matches and the first game of each match. TourneyController is the gateway between the plugin (the data and logic of tournament) and the Drupal entity system.
Plugin designers don't have to extend TourneyController, they can do what ever they want. When tournaments are saved $plugin->build() (mandatory method from TourneyControllerInterface) is called, as well as $plugin->saveMatches() (not in the TourneyControllerInterface, but if exists in plugin it is called).
Plugins should also be able to render themselves. If the plugin designer is using one of the entities provided by tourney module, the entity will call $plugin->render() on the plugin for rendering.