silverorange Code


Site.SiteConfigChecker
/Site/SiteConfigChecker.php at line 17

Class SiteConfigChecker

SwatObject
└─SiteObject
└─SiteApplication
└─SiteCommandLineApplication
└─SiteConfigChecker

public class SiteConfigChecker
extends SiteCommandLineApplication

Command line application for checking if an ini file is valid

Because of the way the site configuration module parses ini properties into PHP properties, all ini settings names must be valid PHP variable names. Additionally, ini properties must be defined to be valid.

Copyright:
2008 silverorange
License:
http://www.gnu.org/copyleft/lesser.html LGPL License 2.1

Fields inherited from Site.SiteCommandLineApplication
VERBOSITY_ALL, VERBOSITY_ERRORS, VERBOSITY_NONE, arguments, documentation, lock_file, title, verbosity
Fields inherited from Site.SiteApplication
VAR_COOKIE, VAR_ENV, VAR_FILES, VAR_GET, VAR_POST, VAR_REQUEST, VAR_SERVER, VAR_SESSION, default_time_zone, id, locale, modules, modules_by_provides
Constructor Summary

SiteConfigChecker(mixed id, mixed title, mixed documentation)

Method Summary
void

addDefinition(string section, string name, string default_value)

Adds a configuration setting definition to this config module.

void

addDefinitions(array definitions)

Adds multiple configuration setting definitions to this config module.

private boolean

check()

Checks an in file to ensure all the fields are defined.

private boolean

isValidKey(string name)

Checks whether or not a name is a valid section name or setting name.

void

run()

Run the application.

void

setFilename(mixed filename)

void

setQuiet(boolean quiet)

Sets whether or not this application is quiet.

Methods inherited from Site.SiteCommandLineApplication
addCommandLineArgument, debug, displayArgumentUsage, displayUsage, error, getLockFilename, getScriptDirectory, lock, output, parseCommandLineArguments, setApplicationDirectory, setVerbosity, terminate, unlock
Methods inherited from Site.SiteApplication
addConfigDefinitions, addDefaultModule, addDefaultModules, addModule, configure, configureErrorHandling, getCountry, getDefaultModuleList, getInstance, getInstanceId, getLocale, getModule, hasModule, initModules, initVar, postInitConfigure, run

Constructor Detail

/Site/SiteConfigChecker.php at line 39

SiteConfigChecker

public SiteConfigChecker(mixed id, mixed title, mixed documentation)

Method Detail

/Site/SiteConfigChecker.php at line 122

addDefinition

public void addDefinition(string section, string name, string default_value)

Adds a configuration setting definition to this config module

Only defined settings may be loaded from an ini file. Other settings will throw exceptions when they are loaded.

Parameters:
section - the section the setting belongs to.
name - the name of the setting.
default_value - optional. The default value of the setting. Used if the setting does exist in the loaded ini file.
Throws:
if the section is not a valid section name. Valid section names follow the rules for PHP identifiers.
if the name is not a valid name. Valid names follow the rules for PHP identifiers.

/Site/SiteConfigChecker.php at line 88

addDefinitions

public void addDefinitions(array definitions)

Adds multiple configuration setting definitions to this config module

Only defined settings may be loaded from an ini file. Other settings will throw exceptions when they are loaded.

Parameters:
definitions - an associative array of setting definitions. The array is of the form: qualified_name => default_value where qualified_name is a string containing the section name and the setting name separated by a '.'. For example, a setting for 'dsn' in the 'database' section would have a qualified name of 'database.dsn'. The default value is a string containing the value to use for the setting if the setting does not exist in the loaded configuration file. Use null to specify no default.
Throws:
if the qualified name does not contain a section and a setting name.

/Site/SiteConfigChecker.php at line 184

check

private boolean check()

Checks an in file to ensure all the fields are defined

Returns:
returns true if the file was parsed successfully and false if not.

/Site/SiteConfigChecker.php at line 226

isValidKey

private boolean isValidKey(string name)

Checks whether or not a name is a valid section name or setting name

Parameters:
name - the name to check.
Returns:
true if the name is valid and false if it is not.

/Site/SiteConfigChecker.php at line 53

run

public void run()

Run the application.


/Site/SiteConfigChecker.php at line 166

setFilename

public void setFilename(mixed filename)

/Site/SiteConfigChecker.php at line 154

setQuiet

public void setQuiet(boolean quiet)

Sets whether or not this application is quiet

Parameters:
quiet - optional. Whether or not this application is quiet. If not specified, defaults to true.

silverorange Code