Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New feature #13513 : allow plugins to add expresssion manager function
- Loading branch information
Showing
6 changed files
with
91 additions
and
23 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
function sayHello(message) { | ||
return "Hello " + message; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
/** | ||
* Example plugin that add a simple function | ||
*/ | ||
class demoAddEmFunction extends PluginBase | ||
{ | ||
static protected $description = 'Demo: adding a new function'; | ||
static protected $name = 'demoAddEmFunction'; | ||
|
||
public function init() | ||
{ | ||
$this->subscribe('newValidFunctions'); | ||
} | ||
|
||
public function newValidFunctions() | ||
{ | ||
Yii::setPathOfAlias(get_class($this),dirname(__FILE__)); | ||
//~ Yii::import(get_class($this).".exampleFunctions"); | ||
$newFunctions = array( | ||
'sayHello' => array( | ||
'\demoAddEmFunction\exampleFunctions::sayHello', // PHP function, no need Class if function is directly added here | ||
'sayHello', // Javascript function | ||
$this->gT("Say hello"), // Description for admin | ||
'string sayHello(string)', // Extra description | ||
'https://www.limesurvey.org', // Help url | ||
1, // Number of argument (time to make a good description of EM … | ||
), | ||
); | ||
$this->getEvent()->append('functions', $newFunctions); | ||
/* For the js file : maybe add a helper on parent ? */ | ||
$newPackage = array( | ||
'demoAddEmFunction'=> array( | ||
//~ 'devBaseUrl' => '/plugins/'.get_class($this)."/assets", | ||
'basePath' => get_class($this).".assets", | ||
// Can be an external url with baseUrl | ||
'js' => array(get_class($this).".js"), | ||
), | ||
); | ||
$this->getEvent()->append('packages', $newPackage); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
/** | ||
* This file is part of reloadAnyResponse plugin | ||
*/ | ||
namespace demoAddEmFunction; | ||
class exampleFunctions | ||
{ | ||
public static function sayHello($message) | ||
{ | ||
return "Hello ".$message; | ||
} | ||
} |