Download the PHP package srag/dic without Composer
On this page you can find all versions of the php package srag/dic. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package dic
srag/dic Library for ILIAS Plugins
Use all ILIAS globals in your class
This project is licensed under the GPL-3.0-only license
Usage
Composer
First add the following to your composer.json
file:
And run a composer install
.
If you deliver your plugin, the plugin has it's own copy of this library and the user doesn't need to install the library.
Tip: Because of multiple autoloaders of plugins, it could be, that different versions of this library exists and suddenly your plugin use an older or a newer version of an other plugin!
So I recommand to use srag/librariesnamespacechanger in your plugin.
ILIAS 7 core ilCtrl patch
For make some plugins work with ilCtrl in ILIAS 7, you may need to patch the core, before you update the plugin (At your own risk)
Start at the plugin directory
Use trait
Declare your class like follow:
ilXPlugin
is the name of your plugin class.
Use
You can now access the DIC interface, in instance and in static places:
For instance you can access the ilCtrl global like:
You can access the plugin interface, in instance and in static places:
The plugin interface has the follow methods:
For plugin dir use:
For output HTML or GUI use:
For output JSON:
For get HTML of GUI:
For get a template use:
For translate use:
Hints:
- Please use not more manually
sprintf
orvsprintf
, use the$placeholders
parameter. Otherwise you will get an appropriate DICException thrown. This becausetranslate
use alwaysvsprintf
and if you pass to few palceholders,vsprintf
will throw an Exception. - Because
translate
usevsprintf
, you need to escape%
with%%
in your language strings if it is no placeholder!
If you really need the ILIAS plugin object use but avoid this:
You can access ILIAS version informations, in instance and in static places:
If you really need DICTrait outside a class (For instance in dbupdate.php
), use DICStatic::dic()
or DICStatic::plugin(ilXPlugin::class)
.
Clean up
You can now remove all usages of ILIAS globals in your class and replace it with this library. Please avoid to store in variables or class variables.
Database
This library delivers also a custom ilDB
decorator class with spec. functions, restricted to PDO
(Because to make access more core functions), access via self:.dic()->database()
If you realy need to access to original ILIAS ilDB
instance, use self:.dic()->databaseCore()
instead
Native AutoIncrement (MySQL) / Native Sequence (PostgreSQL)
Use auto increment on a spec. field (in dbupdate.php
):
Reset auto increment:
Drop auto increment table (Needed for PostgreSQL) (in ilXPlugin
uninstaller):
Store (In repository)
Automatic factory (In repository)
Create or update table
Same thing like ILIAS ActiveRecord
:
If the table not exists, create it, otherwise add missing columns
Multiple insert
PluginVersionParameter
Force reload css or js files on a plugin update (Browser Cache)
Optimal, it's also possible to pass a second URL which used if ILIAS Dev-Mode is enabled (For instance non-min version)
Requirements
- ILIAS 6.0 - 7.999
- PHP >=7.2