1 | <?php |
||
2 | |||
3 | /** |
||
4 | * @package interface |
||
5 | */ |
||
6 | /** |
||
7 | * This interface describes the minimum a new Datasource type needs to |
||
8 | * provide to be able to be used by Symphony |
||
9 | * |
||
10 | * @since Symphony 2.3 |
||
11 | */ |
||
12 | interface iDatasource |
||
0 ignored issues
–
show
|
|||
13 | { |
||
14 | /** |
||
15 | * Returns the human readable name of this Datasource type. This is |
||
16 | * displayed in the datasource 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 datasource in the `DATASOURCES` folder. |
||
25 | * |
||
26 | * @return string |
||
27 | */ |
||
28 | public static function getTemplate(); |
||
29 | |||
30 | /** |
||
31 | * This function return the source of this datasource. It's an artefact |
||
32 | * of old core objects and for the moment it should return the same |
||
33 | * value as `getClass`. |
||
34 | * |
||
35 | * @return string |
||
36 | */ |
||
37 | public function getSource(); |
||
38 | |||
39 | /** |
||
40 | * This function returns all the settings of the current Datasource |
||
41 | * instance. |
||
42 | * |
||
43 | * @return array |
||
44 | * An associative array of settings for this datasource 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 Datasource Editor and allows this |
||
52 | * Datasource 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 Datasource's settings on edit using |
||
66 | * `settings()`. |
||
67 | * @param string $handle |
||
68 | * If the datasource already exists (so it's being edited), the handle |
||
69 | * of the datasource 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 datasource 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 datasource parameters, return |
||
91 | * the contents of this datasource so that can be saved to the file system. |
||
92 | * |
||
93 | * @param array $fields |
||
94 | * An associative array of settings for this datasource, where the key |
||
95 | * is the name of the setting. These are user defined through the Datasource |
||
96 | * Editor. |
||
97 | * @param array $parameters |
||
98 | * An associative array of parameters for this datasource, 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 | * This function is responsible for returning an `XMLElement` so that the |
||
110 | * `FrontendPage` class can add to a page's XML. It is executed and passed |
||
111 | * the current `$param_pool` array. |
||
112 | * |
||
113 | * @param array $param_pool |
||
114 | * An associative array of parameters that have been evaluated prior to |
||
115 | * this Datasource's execution. |
||
116 | * @return XMLElement |
||
117 | * This Datasource should return an `XMLElement` object. |
||
118 | */ |
||
119 | public function execute(array &$param_pool = null); |
||
0 ignored issues
–
show
|
|||
120 | } |
||
121 |
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
.