Is the following if/return for "Quit if is done" neccesary? I noticed it only in answersAsReadonly but not other plugins. I don't understand it...
Code:
public function answersAsReadonlyAddScript()
{
/* Quit if is done */
if(array_key_exists(get_class($this),Yii::app()->getClientScript()->packages)) {
return;
}
/* Add package if not exist (allow to use another one in config) */
if(!Yii::app()->clientScript->hasPackage(get_class($this))) {
Yii::setPathOfAlias(get_class($this),dirname(__FILE__));
Yii::app()->clientScript->addPackage(get_class($this), array(
'basePath' => get_class($this).'.assets',
'css' => array(get_class($this).'.css'),
'js' => array(get_class($this).'.js'),
'depends' =>array('limesurvey-public'),
));
}
/* Registering the package */
Yii::app()->getClientScript()->registerPackage(get_class($this));
}
You can have multiple readonly question : then : do it once.
It's to allow to use own package by other developer too since packlage can be set by config
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member. -
Professional support
-
Plugins, theme and development
. I don't answer to private message.
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member. -
Professional support
-
Plugins, theme and development
. I don't answer to private message.
I don't understand :
- if there are issue : report and make a pull request
- if it' improve without real issue : make a pull request directly.
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member. -
Professional support
-
Plugins, theme and development
. I don't answer to private message.
Got it :
if(array_key_exists(get_class($this),Yii::app()->getClientScript()->packages)) {
the idea is to not register , i must find something like Yii::app()->getClientScript()->isPackageRegistered
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member. -
Professional support
-
Plugins, theme and development
. I don't answer to private message.