_contextId = $contextId; $this->_plugin = $plugin; parent::__construct($plugin->getTemplatePath() . 'settingsForm.tpl'); $this->addCheck(new FormValidatorPost($this)); $this->addCheck(new FormValidatorCSRF($this)); } /** * Get the setting names for this form. * @return array */ private function _getSettingNames() { return array('testMode', 'accountName', 'clientId', 'secret'); } /** * Initialize form data. */ function initData() { $contextId = $this->_contextId; $plugin = $this->_plugin; foreach ($this->_getSettingNames() as $settingName) { $this->setData($settingName, $plugin->getSetting($contextId, $settingName)); } } /** * Assign form data to user-submitted data. */ function readInputData() { $this->readUserVars($this->_getSettingNames()); } /** * Save settings. */ function execute() { $plugin = $this->_plugin; $contextId = $this->_contextId; foreach ($this->_getSettingNames() as $settingName) { $plugin->updateSetting($contextId, $settingName, $this->getData($settingName)); } } }