@param string $setting
@param array $data

@return array
12766
private function get_detail_setting( $setting, $data ) {
		$data['key'] = $setting;
		$type        = $this->app->utility->array_get( $data, 'type', '' );
		$default     = $this->app->utility->array_get( $data, 'default', '' );
		if ( is_callable( $default ) ) {
			$default = $default( $this->app );
		}
		$default = $this->get_expression( $default, $type );
		if ( ! empty( $data['translate'] ) ) {
			$default = $this->app->translate( $default );
		}
		$data['info'] = [];
		if ( '' !== $default ) {
			$data['info'][] = $this->app->translate( 'default' ) . ' = ' . $default;
		}
		if ( isset( $data['min'] ) ) {
			$data['info'][] = $this->app->translate( 'min' ) . ' = ' . $this->get_expression( $data['min'], $type );
		}
		if ( isset( $data['max'] ) ) {
			$data['info'][] = $this->app->translate( 'max' ) . ' = ' . $this->get_expression( $data['max'], $type );
		}
		$data['name']        = $this->get_filter_prefix() . $data['key'];
		$data['saved']       = $this->app->get_option( $data['name'] );
		$data['placeholder'] = $default;
		$value               = $this->apply_filters( $data['key'], $default );
		$data['value']       = $value;
		$data['used']        = $this->get_expression( $value, $type );

		return $data;
	}
1316015
public function write_setting($data) {
        // Try to remove duplicates before storing the contexts (to avoid problems in sync_users()).
        $data = explode(';', $data);
        $data = array_map(function($x) {
            return core_text::strtolower(trim($x));
        }, $data);
        $data = implode(';', array_unique($data));
        return parent::write_setting($data);
    }
537270
public function remove_setting( $setting ) {
		if ( ! $this->is_setting( $setting ) ) {
			return true;
		}

		$priority = $this->_setting_priority[ $setting ];
		unset( $this->_settings[ $priority ][ $setting ] );
		unset( $this->_setting_priority[ $setting ] );
		if ( empty( $this->_settings[ $priority ] ) ) {
			unset( $this->_settings[ $priority ] );
		}
		foreach ( $this->_groups as $group_priority => $groups ) {
			foreach ( $groups as $group => $settings ) {
				$key = array_search( $setting, $settings );
				if ( false !== $key ) {
					unset( $this->_groups[ $group_priority ][ $group ][ $key ] );
					if ( empty( $this->_groups[ $group_priority ][ $group ] ) ) {
						unset( $this->_groups[ $group_priority ][ $group ] );
						unset( $this->_group_priority[ $group ] );
						if ( empty( $this->_groups[ $group_priority ] ) ) {
							unset( $this->_groups[ $group_priority ] );
						}
					}
					break;
				}
			}
		}

		return true;
	}
478278
private function applyOrders(array $settings): array
    {
        $orders = [];
        // Obtain a list of columns
        foreach ($settings as $column => $order) {
            $column = Proxy\Db::quoteIdentifier($column);
            $orders[] = $column . ' ' . $order;
        }
        return $orders;
    }
1084113
private static function parseSetting($setting)
    {
        if (is_string($setting) &&
        false !== strpos($setting, \WebServCo\Framework\Settings::DIVIDER)) {
            return explode(\WebServCo\Framework\Settings::DIVIDER, $setting);
        }
        return $setting;
    }
133657
public function write_setting($data) {
        $validated = $this->validate($data);
        if ($validated !== true) {
            return $validated;
        }
        return parent::write_setting($data);
    }
67158
public function write_setting($data) {
        global $CFG, $DB;

        $oldvalue  = $this->config_read($this->name);
        $return    = parent::write_setting($data);
        $newvalue  = $this->config_read($this->name);

        if ($oldvalue !== $newvalue) {
        // force full regrading
            $DB->set_field('grade_items', 'needsupdate', 1, array('needsupdate'=>0));
        }

        return $return;
    }
1245389
public function get_setting() {
        $result = parent::get_setting();
        if ($result === null) {
            // this is necessary for settings upgrade
            return null;
        }
        if (empty($result)) {
            $result = array('$@NONE@$');
        }
        return $result;
    }
738550
protected function getSettingPlaceholder(FieldTypeInterface $setting): array
    {
        $placeholder = $setting->getOption('placeholder');

        if (is_null($placeholder)) {
            return [];
        }

        return [$setting->getName() => $placeholder];
    }
42544
private function getMappedSettings(array $settingsData): array
    {
        $settings = [];
        foreach ($settingsData as $settingName => $settingValue) {
            $settings[] = new ModuleSetting($settingName, $settingValue);
        }

        return $settings;
    }
1149744
public function write_setting($data) {
        if (!is_array($data)) {
            return ''; // ignore it
        }
        if (!$this->load_choices() or empty($this->choices)) {
            return '';
        }
        unset($data['xxxxx']);
        $result = array();
        foreach ($data as $key => $value) {
            if ($value and array_key_exists($key, $this->choices)) {
                $result[] = $key;
            }
        }
        return $this->config_write($this->name, implode(',', $result)) ? '' : get_string('errorsetting', 'admin');
    }
1163254
public function addSlave(array $setting)
    {
        $database = new Database($setting);
        $database->setMaster($this);
        $this->_slaves[] = $database;
    }
575924
public function write_setting($data) {
        if ((string)$data === $this->yes) { // convert to strings before comparison
            $data = $this->yes;
        } else {
            $data = $this->no;
        }
        return ($this->config_write($this->name, $data) ? '' : get_string('errorsetting', 'admin'));
    }
1363700
public function settings(array $settings = null)
    {
        if ($settings) {
            $this->_settings = array_merge($this->_settings, $settings);
        }
        return $this->_settings;
    }
1239988
public static function encrypt($data, $key, array $setting = [])
    {
        $data = (string) $data;
        if(!is_string($data)){
            throw  new Exception(Exception::CODE_PARAM_ERROR_MSG,Exception::CODE_PARAM_VALUE_ERROR);
        }

        $setting = array_merge(Utils::CRYPT_DEFAULT, $setting);
        $encrypted = openssl_encrypt($data,$setting['cipher'],$key,$setting['options'],$setting['iv']);
        if($encrypted === false){
            throw new Exception('Can not encrypt data',Exception::CODE_PARAM_VALUE_ERROR);
        }
        return base64_encode($encrypted);
    }
289256
public function get_setting() {
        $result = $this->config_read($this->name);

        if (is_null($result)) {
            return NULL;
        }
        if ($result === '') {
            return array();
        }
        $enabled = explode(',', $result);
        $setting = array();
        foreach ($enabled as $option) {
            $setting[$option] = 1;
        }
        return $setting;
    }
125396
private function getMappedSettings(array $settings, $fromIndex, $toIndex)
    {
        $mappedSettings = ['sourceOrder' => [], 'sources' => []];

        if (isset($settings['sourceOrder'])) {
            foreach ($settings['sourceOrder'] as $row) {
                if ('key' == $row[0]) {
                    $row[1] = $this->getSource('', $row[1], $fromIndex, $toIndex);
                }
                $mappedSettings['sourceOrder'][] = $row;
            }
        }

        if (isset($settings['sources'])) {
            foreach ($settings['sources'] as $source => $sourceSettings) {
                $mappedSource = $this->getSource('', $source, $fromIndex, $toIndex);
                $mappedSettings['sources'][$mappedSource] = [
                  'tableAttributes' => $this->getSources('', $sourceSettings['tableAttributes'], $fromIndex, $toIndex),
                ];
            }
        }

        return $mappedSettings;
    }