Actions

Dynamic model events

From LimeSurvey Manual

Revision as of 12:27, 11 October 2018 by DenisChenu (talk | contribs) (Add {{FeatureStarting|3.5.1}})
 Hint: This features is available starting in version 3.5.1


When

Like Specific Model events.

Input

  • model : The current model as a ActiveRecord
  • dynamicId : if model extend Dynamic model ( ie Token and Response ). The related dynamic id
  • iSurveyID and iSurveyID : The survey id if model is related to a survey id ( ie Token, TokenDynamic, Response, SurveyDynamic, Timing, SurveyTimingDynamic)

Possible output

None.

Example of usage

See AuditLog

    function init()
    {
        $this->subscribe('afterTokenSave');
        $this->subscribe('afterTokenDynamicSave','afterTokenSave');
    }

public function afterTokenSave()
{   
    $surveyId = $this->getEvent()->get('surveyId');
    if (empty($surveyId)) {
        // Something strange happen
    } else {
        // Log it somewhere
        $oToken = $this->getEvent()->get('model');
        $this->log($oToken->token." updated in survey".$surveyId);
    }
}