Skip to content

Instantly share code, notes, and snippets.

@Shnoulle
Last active July 2, 2019 17:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Shnoulle/39bb12a2bf8628dd607250510fe36e47 to your computer and use it in GitHub Desktop.
Save Shnoulle/39bb12a2bf8628dd607250510fe36e47 to your computer and use it in GitHub Desktop.
LimeSurvey CLI event example
<?php
/**
* CLI events of LimeSurvey
* To be move to limesurvey/plugins/cliEvent directory
*
* @author Denis Chenu <denis@sondages.pro>
* @copyright 2016-2019 Denis Chenu <http://www.sondages.pro>
* @license WTFPL (Do What The Fuck You Want to Public License)
* @version 0.1.0
*
*/
class cliEvent extends PluginBase
{
static protected $name = 'cliEvent';
static protected $description = 'Usage of CLI event';
public function init()
{
$this->subscribe('cron');
$this->subscribe('direct');
}
/**
* Event cron happen
* Usage : cron [--interval=]
* @return @void
*/
public function cron()
{
echo "Event cron happen\n";
echo "With interval: ".$this->event->get("interval")."\n";
}
/**
* 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";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment