Last active
July 2, 2019 17:01
-
-
Save Shnoulle/39bb12a2bf8628dd607250510fe36e47 to your computer and use it in GitHub Desktop.
LimeSurvey CLI event example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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