PHP Class Piwik\Config

This class reads and writes to the config/config.ini.php file. If config options are missing from that file, this class will look for their default values in config/global.ini.php. ### Examples **Getting a value:** read the minimum_memory_limit option under the [General] section $minValue = Config::getInstance()->General['minimum_memory_limit']; **Setting a value:** set the minimum_memory_limit option Config::getInstance()->General['minimum_memory_limit'] = 256; Config::getInstance()->forceSave(); **Setting an entire section:** Config::getInstance()->MySection = array('myoption' => 1); Config::getInstance()->forceSave();
Inheritance: extends piwik\Singleton
Afficher le fichier Open project: piwik/piwik Class Usage Examples

Protected Properties

Свойство Type Description
$doNotWriteConfigInTests boolean
$settings Piwik\Application\Kernel\GlobalSettingsProvider

Méthodes publiques

Méthode Description
__construct ( Piwik\Application\Kernel\GlobalSettingsProvider $settings )
__get ( string $name ) : string | array Returns a configuration value or section by name.
__set ( string $name, mixed $value ) Sets a configuration value or section.
clear ( ) Clear in-memory configuration so it can be reloaded
deleteLocalConfig ( )
dumpConfig ( ) : string | null Dump config
existsLocalConfig ( )
forceSave ( ) Writes the current configuration to the **config.ini.php** file. Only writes options whose values are different from the default.
forceUsageOfLocalHostnameConfig ( string $hostname ) : string If set, Piwik will use the hostname config no matter if it exists or not. Useful for instance if you want to create a new hostname config:
getByDomainConfigPath ( )
getClientSideOptions ( )
getCommonConfigPath ( ) : string Returns absolute path to the common configuration file.
getCommonPath ( ) : string Returns the path to the common config file used by this instance.
getConfigHostnameIfSet ( )
getConfigNotWritableException ( )
getFromCommonConfig ( $name )
getFromGlobalConfig ( $name )
getFromLocalConfig ( $name )
getGlobalConfigPath ( ) : string Returns absolute path to the global configuration file
getGlobalPath ( ) : string Returns the path to the global config file used by this instance.
getHostname ( ) : string Returns the hostname of the current request (without port number)
getInstance ( ) : Config
getLocalConfigPath ( ) : string Returns absolute path to the local configuration file
getLocalPath ( ) : string Returns the path to the local config file used by this instance.
init ( ) Read configuration from files into memory
isFileWritable ( ) : boolean Returns true if the local configuration file is writable.

Méthodes protégées

Méthode Description
reload ( $pathLocal = null, $pathGlobal = null, $pathCommon = null ) Reloads config data from disk.
writeConfig ( boolean $clear = true ) Write user configuration file

Private Methods

Méthode Description
getDatatableRowLimits ( ) : mixed
getLocalConfigInfoForHostname ( $hostname )

Method Details

__construct() public méthode

public __construct ( Piwik\Application\Kernel\GlobalSettingsProvider $settings )
$settings Piwik\Application\Kernel\GlobalSettingsProvider

__get() public méthode

Returns a configuration value or section by name.
public __get ( string $name ) : string | array
$name string The value or section name.
Résultat string | array The requested value requested. Returned by reference.

__set() public méthode

Sets a configuration value or section.
public __set ( string $name, mixed $value )
$name string This section name or value name to set.
$value mixed

clear() public méthode

Clear in-memory configuration so it can be reloaded
Deprecation: since v2.12.0
public clear ( )

deleteLocalConfig() public méthode

public deleteLocalConfig ( )

dumpConfig() public méthode

Dump config
public dumpConfig ( ) : string | null
Résultat string | null

existsLocalConfig() public méthode

Deprecation:
public existsLocalConfig ( )

forceSave() public méthode

Writes the current configuration to the **config.ini.php** file. Only writes options whose values are different from the default.
public forceSave ( )

forceUsageOfLocalHostnameConfig() public méthode

$config = Config::getInstance(); $config->forceUsageOfHostnameConfig('piwik.example.com'); $config->save();
public forceUsageOfLocalHostnameConfig ( string $hostname ) : string
$hostname string eg piwik.example.com
Résultat string

getByDomainConfigPath() public static méthode

public static getByDomainConfigPath ( )

getClientSideOptions() public méthode

getCommonConfigPath() public static méthode

Returns absolute path to the common configuration file.
public static getCommonConfigPath ( ) : string
Résultat string

getCommonPath() public méthode

Returns the path to the common config file used by this instance.
public getCommonPath ( ) : string
Résultat string

getConfigHostnameIfSet() public méthode

getConfigNotWritableException() public méthode

getFromCommonConfig() public méthode

public getFromCommonConfig ( $name )

getFromGlobalConfig() public méthode

public getFromGlobalConfig ( $name )

getFromLocalConfig() public méthode

public getFromLocalConfig ( $name )

getGlobalConfigPath() public static méthode

Returns absolute path to the global configuration file
public static getGlobalConfigPath ( ) : string
Résultat string

getGlobalPath() public méthode

Returns the path to the global config file used by this instance.
public getGlobalPath ( ) : string
Résultat string

getHostname() public static méthode

Returns the hostname of the current request (without port number)
public static getHostname ( ) : string
Résultat string

getInstance() public static méthode

public static getInstance ( ) : Config
Résultat Config

getLocalConfigPath() public static méthode

Returns absolute path to the local configuration file
public static getLocalConfigPath ( ) : string
Résultat string

getLocalPath() public méthode

Returns the path to the local config file used by this instance.
public getLocalPath ( ) : string
Résultat string

init() public méthode

Read configuration from files into memory
Deprecation: since v2.12.0
public init ( )

isFileWritable() public méthode

Returns true if the local configuration file is writable.
public isFileWritable ( ) : boolean
Résultat boolean

reload() protected méthode

Reloads config data from disk.
protected reload ( $pathLocal = null, $pathGlobal = null, $pathCommon = null )

writeConfig() protected méthode

Write user configuration file
protected writeConfig ( boolean $clear = true )
$clear boolean

Property Details

$doNotWriteConfigInTests protected_oe property

protected bool $doNotWriteConfigInTests
Résultat boolean

$settings protected_oe property

protected GlobalSettingsProvider,Piwik\Application\Kernel $settings
Résultat Piwik\Application\Kernel\GlobalSettingsProvider