...
Set up a new Plugin in the directory app/Plugin/MyPlugin
. You might find it handy to use Cake's bake
command.
Code Block |
---|
$ cd app
$ ./Console/cake bake plugin MyPlugin
|
...
- Create a Model whose name matches the name of the Plugin. In this example, the Model is created at
app/Plugin/MyPlugin/Model/MyPlugin.php
. Define
$cmPluginType
to indicate the type of the Plugin, from the following options:$cmPluginType
Description
enroller
Enrollment Flow Plugin normalizer
Normalization Plugin
provisioner
Provisioning Plugin
other
Any other type of Plugin
Here's an example Model:
Code Block |
---|
class LdapProvisioner extends AppModel {
// Required by COmanage Plugins
public $cmPluginType = "provisioner";
}
|
...
Once the file is created, the database schema will automatically be updated by the normal mechanism:
Code Block |
---|
$ cd app
$ ./Console/cake database
|
...
In order for deletes to cascade successfully when the parent object is deleted, you must specify any dependencies your plugin has. (Failure to do so will result in foreign key violation errors when the parent object is deleted.) To do so, define an array $cmPluginHasMany
in Model/MyPlugin.php
, which consists of an array where the keys are the model the foreign key points to and the values are the name of the model they point from.
For example:
Code Block |
---|
// Document foreign keys
public $cmPluginHasMany = array(
"CoPerson" => array("CoChangelogProvisionerExport")
);
|
...
Do not hardcode display texts, but instead create lookup files that translate keys into language specific texts. For now, Registry uses a custom mechanism for I18N/L10N (CO-351). Use _txt(key)
or _txt(key, array(param1, param2))
in your code to generate language-specific text, and then define those keys in the file Plugin/MyPlugin/Lib/lang.php
:
Code Block |
---|
// When localizing, the number in format specifications (eg: %1$s) indicates the argument
// position as passed to _txt. This can be used to process the arguments in
// a different order than they were passed.
$cm_my_plugin_texts['en_US'] = array(
// Titles, per-controller
'ct.co_my_plugin_model.1' => 'My Plugin Model',
'ct.co_my_plugin_model.pl' => 'My Plugin Models',
// Plugin texts
'pl.myplugin.someparam' => 'Some Parameter',
'pl.myplugin.another' => 'Another Parameter'
);
|
...
Menu Location Key | Menu Location | Default Permission | CO ID Inserted? | CO Person ID Inserted? |
---|---|---|---|---|
cmp | Platform Menu | CMP Administrator |
|
|
coconfig | Organization Menu / CO Configuration Submenu | CO Administrator |
| |
cos | Organization Menu / CO Submenu | Member of CO |
| |
copeople | Organization Menu / People Submenu | Member of CO |
| |
coperson | My Account Menu | Member of CO |
An example:
Code Block |
---|
/**
* Expose menu items.
*
* @ since COmanage Registry v0.9.2
* @ return Array with menu location type as key and array of labels, controllers, actions as values.
*/
public function cmPluginMenus() {
return array(
"coperson" => array(_txt('pl.dirviewer.viewmenu') =>
array('controller' => "dir_viewers",
'action' => "view"))
);
}
|
...
Plugin Types not listed here have no additional requirements.
Enrollment Flow Plugins
XXX add details
Normalization Plugins
Some additional conventions are required when writing a Normalization Plugin.
...