public function handleRequest(): void
	{
		global $save, $restore;

		$request = $this->getRequest();
		if ((!empty($save) || !empty($restore)) && $request->isPost() && check_bitrix_sessid()) {
			if (!empty($restore)) {
				// Restore defaults
				Option::delete(ADMIN_MODULE_NAME);
				CAdminMessage::showMessage([
					'MESSAGE' => Loc::getMessage('REFERENCES_OPTIONS_RESTORED'),
					'TYPE' => 'OK',
				]);
			} else {
				try {
					// Save options
					foreach ($this->options->getFields() as $id => $opt) {
						switch ($opt['type']) {
							case 'checkbox':
								$value = $request->getPost($id) ? true : false;
								break;

							case 'number':
								$value = (int)$request->getPost($id);
								break;

							case 'text':
							default:
								$value = $request->getPost($id);
								break;
						}

						$event = new Event(ADMIN_MODULE_NAME, 'OnBeforeSetOption_' . $id, ['value' => &$value]);
						$event->send();

						$event = new Event(ADMIN_MODULE_NAME, 'OnBeforeSetOption', ['value' => &$value, 'name' => $id]);
						$event->send();

						Option::set(ADMIN_MODULE_NAME, $id, $value);
					}

					$event = new Event(ADMIN_MODULE_NAME, 'OnAfterSaveOptions');
					$event->send();

					CAdminMessage::showMessage([
						'MESSAGE' => Loc::getMessage('REFERENCES_OPTIONS_SAVED'),
						'TYPE' => 'OK',
					]);
				} catch (\Exception $exception) {
					CAdminMessage::showMessage($exception->getMessage());
				}
			}
		}
	}
public function handleRequest(): void
	{
		global $save, $restore;

		$request = $this->getRequest();
		if ((!empty($save) || !empty($restore)) && $request->isPost() && check_bitrix_sessid()) {
			if (!empty($restore)) {
				// Restore defaults
				Option::delete(ADMIN_MODULE_NAME);
				CAdminMessage::showMessage([
					'MESSAGE' => Loc::getMessage('REFERENCES_OPTIONS_RESTORED'),
					'TYPE' => 'OK',
				]);
			} else {
				try {
					// Save options
					foreach ($this->options->getFields() as $id => $opt) {
						switch ($opt['type']) {
							case 'checkbox':
								$value = $request->getPost($id) ? true : false;
								break;

							case 'number':
								$value = (int)$request->getPost($id);
								break;

							case 'text':
							default:
								$value = $request->getPost($id);
								break;
						}

						$event = new Event(ADMIN_MODULE_NAME, 'OnBeforeSetOption_' . $id, ['value' => &$value]);
						$event->send();

						$event = new Event(ADMIN_MODULE_NAME, 'OnBeforeSetOption', ['value' => &$value, 'name' => $id]);
						$event->send();

						Option::set(ADMIN_MODULE_NAME, $id, $value);
					}

					$event = new Event(ADMIN_MODULE_NAME, 'OnAfterSaveOptions');
					$event->send();

					CAdminMessage::showMessage([
						'MESSAGE' => Loc::getMessage('REFERENCES_OPTIONS_SAVED'),
						'TYPE' => 'OK',
					]);
				} catch (\Exception $exception) {
					CAdminMessage::showMessage($exception->getMessage());
				}
			}
		}
	}
public function handleRequest ( ) : void { global $ save , $ restore ; $ request = $ this -> getRequest ( ) ; if ( ( ! empty ( $ save ) || ! empty ( $ restore ) ) && $ request -> isPost ( ) && check_bitrix_sessid ( ) ) { if ( ! empty ( $ restore ) ) { // Restore defaults Option :: delete ( ADMIN_MODULE_NAME ) ; CAdminMessage :: showMessage ( [ 'MESSAGE' => Loc :: getMessage ( 'REFERENCES_OPTIONS_RESTORED' ) , 'TYPE' => 'OK' , ] ) ; } else { try { // Save options foreach ( $ this -> options -> getFields ( ) as $ id => $ opt ) { switch ( $ opt [ 'type' ] ) { case 'checkbox' : $ value = $ request -> getPost ( $ id ) ? true : false ; break ; case 'number' : $ value = ( int ) $ request -> getPost ( $ id ) ; break ; case 'text' : default : $ value = $ request -> getPost ( $ id ) ; break ; } $ event = new Event ( ADMIN_MODULE_NAME , 'OnBeforeSetOption_' . $ id , [ 'value' => & $ value ] ) ; $ event -> send ( ) ; $ event = new Event ( ADMIN_MODULE_NAME , 'OnBeforeSetOption' , [ 'value' => & $ value , 'name' => $ id ] ) ; $ event -> send ( ) ; Option :: set ( ADMIN_MODULE_NAME , $ id , $ value ) ; } $ event = new Event ( ADMIN_MODULE_NAME , 'OnAfterSaveOptions' ) ; $ event -> send ( ) ; CAdminMessage :: showMessage ( [ 'MESSAGE' => Loc :: getMessage ( 'REFERENCES_OPTIONS_SAVED' ) , 'TYPE' => 'OK' , ] ) ; } catch ( \ Exception $ exception ) { CAdminMessage :: showMessage ( $ exception -> getMessage ( ) ) ; } } } }
Handle options save request
@throws \Bitrix\Main\ArgumentNullException
Handle options save request