1 | <?php |
||
2 | |||
3 | /** |
||
4 | * @package interface |
||
5 | */ |
||
6 | /** |
||
7 | * This interface describes the minimum a new Event type needs to |
||
8 | * provide to be able to be used by Symphony |
||
9 | * |
||
10 | * @since Symphony 2.3.1 |
||
11 | */ |
||
12 | interface iEvent |
||
0 ignored issues
–
show
|
|||
13 | { |
||
14 | /** |
||
15 | * Returns the human readable name of this event type. This is |
||
16 | * displayed in the event selection options. |
||
17 | * |
||
18 | * @return string |
||
19 | */ |
||
20 | public static function getName(); |
||
21 | |||
22 | /** |
||
23 | * Returns the absolute path to the template that this template will |
||
24 | * use to save instances of this event in the `events` folder. |
||
25 | * |
||
26 | * @return string |
||
27 | */ |
||
28 | public static function getTemplate(); |
||
29 | |||
30 | /** |
||
31 | * Returns the `__CLASS__` on the provided event, this is often |
||
32 | * used as a way to namespace settings in forms and provide a unique |
||
33 | * handle for this event type |
||
34 | * |
||
35 | * @return string |
||
36 | */ |
||
37 | public static function getSource(); |
||
38 | |||
39 | /** |
||
40 | * This function returns all the settings of the current event |
||
41 | * instance. |
||
42 | * |
||
43 | * @return array |
||
44 | * An associative array of settings for this event where the |
||
45 | * key is `getClass` and the value is an associative array of settings, |
||
46 | * key being the setting name, value being, the value |
||
47 | */ |
||
48 | public function settings(); |
||
49 | |||
50 | /** |
||
51 | * This function is invoked by the Event Editor and allows this |
||
52 | * event to provide HTML so that it can be created or edited. |
||
53 | * It is expected that this function will also handle the display |
||
54 | * of error messages. |
||
55 | * |
||
56 | * @see settings() |
||
57 | * @param XMLElement $wrapper |
||
58 | * An XMLElement for the HTML to be appended to. This is usually |
||
59 | * `AdministrationPage->Form`. |
||
60 | * @param array $errors |
||
61 | * If there are any errors, this variable will be an associative |
||
62 | * array, key being the setting handle. |
||
63 | * @param array $settings |
||
64 | * An associative array of settings. This may be null on create, but |
||
65 | * will be populated with the event's settings on edit using |
||
66 | * `settings()`. |
||
67 | * @param string $handle |
||
68 | * If the event already exists (so it's being edited), the handle |
||
69 | * of the event will be passed to this function. |
||
70 | * @return |
||
71 | */ |
||
72 | public static function buildEditor(XMLElement $wrapper, array &$errors = array(), array $settings = null, $handle = null); |
||
0 ignored issues
–
show
|
|||
73 | |||
74 | /** |
||
75 | * Given an array of settings, validate them, adding any errors |
||
76 | * to the `$errors` variable which is passed by reference. `$errors` |
||
77 | * should be formatted as an associative array |
||
78 | * |
||
79 | * @param array $settings |
||
80 | * An associative array of settings |
||
81 | * @param array $errors |
||
82 | * Passed as an empty array, can be populated with any validation errors |
||
83 | * @return boolean |
||
84 | * true if the event is valid, false otherwise. |
||
85 | * If false it is expected that `$errors` are populated. |
||
86 | */ |
||
87 | public static function validate(array &$settings, array &$errors); |
||
88 | |||
89 | /** |
||
90 | * Given the settings and any existing event parameters, return the contents |
||
91 | * of this event that can be saved to the filesystem. |
||
92 | * |
||
93 | * @param array $fields |
||
94 | * An associative array of settings for this event, where the key |
||
95 | * is the name of the setting. These are user defined through the event |
||
96 | * Editor. |
||
97 | * @param array $parameters |
||
98 | * An associative array of parameters for this event, where the key |
||
99 | * is the name of the parameter. |
||
100 | * @param string $template |
||
101 | * The template file, which has already been altered by Symphony to remove |
||
102 | * any named tokens (ie. `<!-- CLASS NAME -->`). |
||
103 | * @return string |
||
104 | * The completed template, ready to be saved. |
||
105 | */ |
||
106 | public static function prepare(array $fields, array $parameters, $template); |
||
107 | |||
108 | /** |
||
109 | * Return an associative array of meta information about this event such |
||
110 | * creation date, who created it and the name. |
||
111 | * |
||
112 | * @return array |
||
113 | */ |
||
114 | public static function about(); |
||
115 | |||
116 | /** |
||
117 | * The load functions determines whether an event will be executed or not |
||
118 | * by comparing the Event's action with the `$_POST` data. This function will |
||
119 | * be called every time a page is loaded that an event is attached too. If the |
||
120 | * action does exist, it typically calls the `__trigger()` method, otherwise void. |
||
121 | * |
||
122 | * @return mixed |
||
123 | * XMLElement with the event result or void if the action did not match |
||
124 | */ |
||
125 | public function load(); |
||
126 | |||
127 | /** |
||
128 | * This function actually executes the event, and returns the result of the |
||
129 | * event as an `XMLElement` so that the `FrontendPage` class can add to |
||
130 | * a page's XML. |
||
131 | * |
||
132 | * @return XMLElement |
||
133 | * This event should return an `XMLElement` object. |
||
134 | */ |
||
135 | public function execute(); |
||
136 | } |
||
137 |
Classes in PHP are usually named in CamelCase.
In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. The whole name starts with a capital letter as well.
Thus the name database provider becomes
DatabaseProvider
.