Table of Contents

How to create a plugin coordinator

The plugin permit to extend the possibilities of the framework / of your application

Its plugins are of 8 types :

This article will address the plugin type "Coord".

A plugin coord permit to act before/during/after the action of a controler.

The advantage of this, is to code once and for all, a behavior when an action occurs, rather than putting in a business class that same code and call to each share with jClasses::inc();

It's more simpler and clearer to read and the controler is more maintenable.

A) Utilisation of plugins Coordinator :

Example : the plugin coord auth of jelix, permits to check if a user is identified.

Its installation is done by adding auth=auth.coord.ini.php in the section coordplugins in the file defaultconfig.ini.php

[coordplugins]
auth=auth.coord.ini.php

then adding adding the array $pluginParams in the controler.

Example 1 :

class adminCtrl extends jController {   
    public $pluginParams = array(
        '*'		=> array('auth.required'=>true));   
   ...
}

here, we ask to Jelix (by the auth coord) that the access of all the action (with the star '*') of the adminCtrl controler can be possible only if the user is identified.

Example 2 :

class adminCtrl extends jController {
    public $pluginParams = array(
        '*'	=>	
             array('auth.required'=>true,
		'hfnu.check.installed'=>true,
		'banuser.check'=>true,
		),
	'index' => array( 'jacl2.right'=>'hfnu.admin.index'),
	'config'=> array( 'jacl2.right'=>'hfnu.admin.config'),
	'check_upgrade'=> array( 'jacl2.right'=>'hfnu.admin.config')
    );
...
}

Here we specify to 4 plugins coord the action to do :

little explanation :

If the user access to http://foobar.com/backoffice/action/admin:index, the ACL plugin check the rights 'hfnu.admin.config', which is set, otherwise, displays a message / returns the user.

B) Make his own plugin of Coordinator :

Now that we saw how we used the plugin coord in a controler, let's see how to code one

a coord plugin is composed of 3 files :

Let's have a look to the coordinator which check that it's application is installed, and if not return the user to the installation page or display an error message.

Here the configuration file will allow the webmaster to determine precisely the behavior: display a message or return the the installation page.

Here is an image with the interaction between the Coordinateur, the config file, and the controller :