Config.php

Summary
Config.php
ConfigTable definition for config
ConfigSuperclass holding a representation of configuration settings and interfaces.
schemaDefReturns a representation of the database schema for the table this superclass itself represents, in an array.
loadSettingsLoad the settings currently stored into the database into the class.
_getSettingsHelper function for loadSettings that does iterating through different settings, checking the cache first and database second.
_applySettingsHelper function to apply configuration settings represented in an associative array into the config class.
insertSave the configuration settings to database.
deleteRemove the configuration settings from the database.
updateUpdates existing configuration settings in the database.
saveGiven a $section, $setting, and $value, save a configuration value in the database.
_blowSettingsCacheA helper function to clear all of the configuration settings we presently have in the settings cache.

Config

Table definition for config

postActiv

the micro-blogging software

Copyright

Copyright © 2016-2017, Maiyannah Bishop

Derived from code copyright various sources

  • GNU Social © 2013-2016, Free Software Foundation, Inc
  • StatusNet © 2008-2012, StatusNet, Inc

License

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program.  If not, see http://www.gnu.org/licenses/.

https://www.gnu.org/licenses/agpl.html

About

Superclass holding a representation of configuration settings and interfaces.

This superclass represents a legacy implementation of holding the configuration settings in the database and is kept mostly for caching purposes.  There’s probably a better way to do this and it is a candidate for revision or removal.

PHP version

Tested with PHP 7

File Authors

Web

Config

Superclass holding a representation of configuration settings and interfaces.

Properties

  • __table = ‘config’ - table name
  • section - varchar(32) primary_key not_null
  • setting - varchar(32) primary_key not_null
  • value - text

Constants

  • settingsKey = ‘config:settings’;
Summary
schemaDefReturns a representation of the database schema for the table this superclass itself represents, in an array.
loadSettingsLoad the settings currently stored into the database into the class.
_getSettingsHelper function for loadSettings that does iterating through different settings, checking the cache first and database second.
_applySettingsHelper function to apply configuration settings represented in an associative array into the config class.
insertSave the configuration settings to database.
deleteRemove the configuration settings from the database.
updateUpdates existing configuration settings in the database.
saveGiven a $section, $setting, and $value, save a configuration value in the database.
_blowSettingsCacheA helper function to clear all of the configuration settings we presently have in the settings cache.

schemaDef

public static function schemaDef()

Returns a representation of the database schema for the table this superclass itself represents, in an array.

loadSettings

static function loadSettings()

Load the settings currently stored into the database into the class.  FIXME: This silently drops errors.

_getSettings

static function _getSettings()

Helper function for loadSettings that does iterating through different settings, checking the cache first and database second.

Returns

  • array containing all the retrieved settings

_applySettings

static function _applySettings($settings)

Helper function to apply configuration settings represented in an associative array into the config class.

insert

function insert()

Save the configuration settings to database.

delete

function delete($useWhere = false)

Remove the configuration settings from the database.

update

function update($dataObject = false)

Updates existing configuration settings in the database.

save

static function save($section,
$setting,
$value)

Given a $section, $setting, and $value, save a configuration value in the database.

Returns

  • result of the insertion function

_blowSettingsCache

function _blowSettingsCache()

A helper function to clear all of the configuration settings we presently have in the settings cache.

public static function schemaDef()
Returns a representation of the database schema for the table this superclass itself represents, in an array.
static function loadSettings()
Load the settings currently stored into the database into the class.
static function _getSettings()
Helper function for loadSettings that does iterating through different settings, checking the cache first and database second.
static function _applySettings($settings)
Helper function to apply configuration settings represented in an associative array into the config class.
function insert()
Save the configuration settings to database.
function delete($useWhere = false)
Remove the configuration settings from the database.
function update($dataObject = false)
Updates existing configuration settings in the database.
static function save($section,
$setting,
$value)
Given a $section, $setting, and $value, save a configuration value in the database.
function _blowSettingsCache()
A helper function to clear all of the configuration settings we presently have in the settings cache.