Direct (command): Difference between revisions
From LimeSurvey Manual
DenisChenu (talk | contribs) (Created page with "{{FeatureStarting|2.63.0}} '''Usage''' This event is used for Command Line Interface usage. '''How to use''' This event needs to be called with php cli command. <code>php...") |
DenisChenu (talk | contribs) (Add example) |
||
Line 7: | Line 7: | ||
'''How to use''' | '''How to use''' | ||
This event needs to be called with php cli command. | This event needs to be called with php cli command (default action). | ||
< | |||
<syntaxhighlight lang="bash">php yourlimesurveydir/application/commands/console.php plugin index --target=examplePluginName</syntaxhighlight> | |||
Or | Or | ||
<syntaxhighlight lang="bash">php yourlimesurveydir/application/commands/console.php plugin --target=examplePluginName</syntaxhighlight> | |||
'''Input''' | '''Input''' | ||
Line 21: | Line 21: | ||
* '''option''' mixed : extra param for plugin if needed, optionnal. | * '''option''' mixed : extra param for plugin if needed, optionnal. | ||
'''Example''' | |||
<syntaxhighlight lang="php"> | |||
/** | |||
* Event direct happen | |||
* Usage : index --target=value [--function=] [--option=] | |||
* @return @void | |||
*/ | |||
public function direct() | |||
{ | |||
echo "Event direct happen\n"; | |||
if($this->event->get("target") != get_class()) { | |||
echo "But target is not this plugin, then quit\n"; | |||
return; | |||
} | |||
echo "Target is this plugin.\n"; | |||
echo "Function call is ".$this->event->get("function")."\n"; | |||
echo "With option: ".$this->event->get("option")."\n"; | |||
} | |||
</syntaxhighlight> | |||
See [https://gist.github.com/Shnoulle/39bb12a2bf8628dd607250510fe36e47 cliEvent.php] gist | |||
[[Category:Plugins events]] | [[Category:Plugins events]] |
Latest revision as of 12:44, 22 September 2017
Hint: This features is available starting in version 2.63.0
Usage
This event is used for Command Line Interface usage.
How to use
This event needs to be called with php cli command (default action).
php yourlimesurveydir/application/commands/console.php plugin index --target=examplePluginName
Or
php yourlimesurveydir/application/commands/console.php plugin --target=examplePluginName
Input
The event receives the following information:
- target string : the plugin name, usage is to use it for target of action.
- function mixed : extra param for plugin if needed, optionnal. Usage use as string.
- option mixed : extra param for plugin if needed, optionnal.
Example
/**
* Event direct happen
* Usage : index --target=value [--function=] [--option=]
* @return @void
*/
public function direct()
{
echo "Event direct happen\n";
if($this->event->get("target") != get_class()) {
echo "But target is not this plugin, then quit\n";
return;
}
echo "Target is this plugin.\n";
echo "Function call is ".$this->event->get("function")."\n";
echo "With option: ".$this->event->get("option")."\n";
}
See cliEvent.php gist