-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.gtw
105 lines (75 loc) · 3.49 KB
/
index.gtw
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
~~LANG:FR@frman:plugins~~
Different types of plugins exists for Jelix. Each categories modify or add functionality
to differents parts of Jelix. There are coordinator plugins, jDb drivers, jAuth drivers,
jTpl plugins...
All plugins are located in plugins //repositories//.
===== Adding a plugins repository =====
You can add one or more plugins repositories. It is a directory with a strict
subtree structure.
Each plugins repository must be declared with @@C@jApp@@ or in the composer.json file
(in previous version, it was in the @@pluginsPath@@ parameter in the configuration).
Here is an example with @@C@jApp@@, into @@application.init.php@@:
<code php>
jApp::declarePluginsDir(__DIR__.'/plugins/');
</code>
Here the plugins directory of the application.
Some directories are declared automatically. This is the case of @@F@lib/jelix/plugins/@@.
it contains all plugins bundled with Jelix. It also loads all @@F@plugins/@@ directories
found into modules.
If you install some packages for Jelix with Composer, plugins directories
can be declared automatically by specifying them into the composer.json file
of the packages.
<code json>
{
...
"extra" : {
"jelix": {
"plugins-dir" : [
"plugins/",
]
}
}
}
</code>
Here, this composer.json file declare the @@F@plugins/@@ which is in the
same directory of composer.json.
It works also with the composer.json of the application.
===== Repository structure and plugins creation =====
A plugins repository has one sub-directory for each plugin type. And within each
sub-directory, each plugin has its own folder.
Below is the list of some plugins type and their respective directory:
* coordinator plugins: @@F@coord/@@
* plugins for jLog: @@F@logger/@@
* jAuth drivers: @@F@auth/@@
* jAcl2 drivers: @@F@acl2/@@
* jDb drivers: @@F@db/@@
* jDao drivers: @@F@daobuilder/@@
* templates plugins: @@F@tpl/@@
* jForms generators: @@F@jforms/@@
* jKVDb drivers: @@F@kvdb/@@
* jCache drivers: @@F@cache/@@
* plugins for the debugbar: @@F@debugbar/@@
* plugins for jResponseHtml: @@F@htmlresponse/@@
* plugins for jProfiles: @@F@profiles/@@
===== Plugins loading =====
Components which are using plugins, load them with the method @@jApp::loadPlugin()@@.
You could need it too to load a plugin, in order to retrieve its configuration or to use it.
To instancy it, you have several parameters. Th first is the plugin name, then, the plugin
type ('db', 'acl'...), the suffix of the file name ('.dbconnection.php'..), the class
name ('mysqliDbConnection') and the last one: a parameter for the constructor.
<code php>
$plugin = jApp::loadPlugin('mysqli'', 'db', '.dbconnection.php', 'mysqliDbConnection', 'default');
</code>
You see that there is a limitation: you cannot give several parameters to the constructor.
You could then simply load the plugin with @@jApp::includePlugin()@@, and instancying
it yourself. This method has same parameters as @@loadPlugin()@@, without the parameter
for the constructor of course.
<code php>
jApp::includePlugin('mysqli'', 'db', '.dbconnection.php', 'mysqliDbConnection');
$plugin = new mysqliDbConnection('default');
</code>
===== Plugins development =====
Jelix comes with a bunch of plugins within the standard package. They are located in
@@F@lib/jelix/plugins/@@. However, it is often useful to create your own plugins to
fulfill specific needs. And If your plugin is generic or useful enough, you're likely to
push it to the developers team :-).