PHP Class Bolt\Config

Author: Bob den Otter, [email protected]
Datei anzeigen Open project: bolt/bolt Class Usage Examples

Public Properties

Property Type Description
$fields Bolt\Storage\Field\Manager Will be made protected in Bolt 3.0.
$notify_update boolean @deprecated Deprecated since 3.2, to be removed in 4.0

Protected Properties

Property Type Description
$app Silex\Application
$cachetimestamp integer
$data array
$defaultConfig array
$reservedFieldNames array
$yamlParser Symfony\Component\Yaml\Parser

Public Methods

Method Description
__construct ( Silex\Application $app )
cacheConfig ( boolean $force = false )
checkConfig ( ) : boolean Sanity checks for doubles in in contenttypes.
doReplacements ( mixed $value = null ) : mixed Replaces placeholders in config values %foo% will be resolved to $app['foo'] from the container
get ( string $path, string | array | boolean $default = null ) : mixed Get a config value, using a path.
getConfig ( ) : array Load the configuration from the various YML files.
getCurrentTimestamp ( ) : string Get the current timestamp, corrected to the timezone.
getExceptions ( ) : array | null
getFields ( ) : Manager A getter to access the fields manager.
getTimestamp ( $when ) : string Get a timestamp, corrected to the timezone.
getTwigPath ( ) : string[] Build an array of Twig paths.
getWhichEnd ( ) : string Use {@see Zone} instead with a {@see Request}.
initialize ( )
set ( string $path, mixed $value ) : boolean Set a config value, using a path.
setCKPath ( )

Protected Methods

Method Description
checkValidCache ( )
getDefaults ( ) Assume sensible defaults for a number of options.
loadCache ( ) : array | null Attempt to load cached configuration files.
parseConfigYaml ( string $filename, string $path = null ) : array Read and parse a YAML configuration file
parseConnectionParams ( array | string $params, array $defaults = [] ) : array Parses params to valid connection parameters: - Defaults are merged into the params - Bolt keys are converted to Doctrine keys - Invalid keys are filtered out
parseContentType ( string $key, array $contentType, array $generalConfig ) : array Parse a single Contenttype configuration array.
parseContentTypes ( array $generalConfig ) : array Read and parse the contenttypes.yml configuration file.
parseDatabase ( array $options ) : array Parse and fine-tune the database configuration.
parseFieldsAndGroups ( array $fields, array $generalConfig ) : array Parse a Contenttype's filed and determine the grouping
parseGeneral ( ) : array Read and parse the config.yml and config_local.yml configuration files.
parseSqliteOptions ( array $config ) : array Fine-tune Sqlite configuration parameters.
parseTaxonomy ( ) : array Read and parse the taxonomy.yml configuration file.
parseTemplatefields ( ) This method pulls the templatefields config from the theme config and appends it to the contenttypes configuration.
parseTheme ( string $themePath, array $generalConfig ) : array Read and parse the current theme's config.yml configuration file.
saveCache ( )

Private Methods

Method Description
checkTaxonomy ( ) : boolean Sanity check for slashes in in taxonomy slugs.
determineZone ( )
invalidateCache ( ) Invalidate (remove) the cache file.
isCacheValid ( ) : boolean Check if the cached config file exists, and is newer than the authoritative source.
isThemeCacheValid ( ) : boolean Check if the cache is still valid with theme file as well.
loadTheme ( ) Checks if cache is valid for theme; if not invalidate and load it.
parseFieldRepeaters ( array $fields, string $key ) : array Basic validation of repeater fields.

Method Details

__construct() public method

public __construct ( Silex\Application $app )
$app Silex\Application

cacheConfig() public method

public cacheConfig ( boolean $force = false )
$force boolean

checkConfig() public method

Sanity checks for doubles in in contenttypes.
public checkConfig ( ) : boolean
return boolean

checkValidCache() protected method

Deprecation: Deprecated since 3.2, to be removed in 4.0.
protected checkValidCache ( )

doReplacements() public method

Replaces placeholders in config values %foo% will be resolved to $app['foo'] from the container
public doReplacements ( mixed $value = null ) : mixed
$value mixed
return mixed

get() public method

For example: $var = $config->get('general/wysiwyg/ck/contentsCss');
public get ( string $path, string | array | boolean $default = null ) : mixed
$path string
$default string | array | boolean
return mixed

getConfig() public method

Load the configuration from the various YML files.
public getConfig ( ) : array
return array

getCurrentTimestamp() public method

Get the current timestamp, corrected to the timezone.
public getCurrentTimestamp ( ) : string
return string Current timestamp

getDefaults() protected method

Assume sensible defaults for a number of options.
protected getDefaults ( )

getExceptions() public method

public getExceptions ( ) : array | null
return array | null

getFields() public method

A getter to access the fields manager.
public getFields ( ) : Manager
return Bolt\Storage\Field\Manager

getTimestamp() public method

Get a timestamp, corrected to the timezone.
public getTimestamp ( $when ) : string
return string Timestamp

getTwigPath() public method

Build an array of Twig paths.
public getTwigPath ( ) : string[]
return string[]

getWhichEnd() public method

Going forward, decisions determined by current request should be done in an app or route middleware. Application should be setup agnostic to the current request. Route middlewares apply only to a certain route or group of routes. See {@see \Bolt\Controller\Async\AsyncBase::before} for an example. App middlewares apply to all routes. See classes in \Bolt\EventListener for examples of these. These middlewares could also be filtered by checking for Zone inside of listener.
Deprecation: Deprecated since 3.0, to be removed in 4.0.
public getWhichEnd ( ) : string
return string

initialize() public method

public initialize ( )

loadCache() protected method

Attempt to load cached configuration files.
protected loadCache ( ) : array | null
return array | null

parseConfigYaml() protected method

Read and parse a YAML configuration file
protected parseConfigYaml ( string $filename, string $path = null ) : array
$filename string The name of the YAML file to read
$path string The (optional) path to the YAML file
return array

parseConnectionParams() protected method

Parses params to valid connection parameters: - Defaults are merged into the params - Bolt keys are converted to Doctrine keys - Invalid keys are filtered out
protected parseConnectionParams ( array | string $params, array $defaults = [] ) : array
$params array | string
$defaults array
return array

parseContentType() protected method

Parse a single Contenttype configuration array.
protected parseContentType ( string $key, array $contentType, array $generalConfig ) : array
$key string
$contentType array
$generalConfig array
return array

parseContentTypes() protected method

Read and parse the contenttypes.yml configuration file.
protected parseContentTypes ( array $generalConfig ) : array
$generalConfig array
return array

parseDatabase() protected method

Parse and fine-tune the database configuration.
protected parseDatabase ( array $options ) : array
$options array
return array

parseFieldsAndGroups() protected method

Parse a Contenttype's filed and determine the grouping
protected parseFieldsAndGroups ( array $fields, array $generalConfig ) : array
$fields array
$generalConfig array
return array

parseGeneral() protected method

Read and parse the config.yml and config_local.yml configuration files.
protected parseGeneral ( ) : array
return array

parseSqliteOptions() protected method

Fine-tune Sqlite configuration parameters.
protected parseSqliteOptions ( array $config ) : array
$config array
return array

parseTaxonomy() protected method

Read and parse the taxonomy.yml configuration file.
protected parseTaxonomy ( ) : array
return array

parseTemplatefields() protected method

This method pulls the templatefields config from the theme config and appends it to the contenttypes configuration.
protected parseTemplatefields ( )

parseTheme() protected method

Read and parse the current theme's config.yml configuration file.
protected parseTheme ( string $themePath, array $generalConfig ) : array
$themePath string
$generalConfig array
return array

saveCache() protected method

Deprecation: Deprecated since 3.2, to be removed in 4.0. Now handled in a listener.
protected saveCache ( )

set() public method

For example: $app['config']->set('general/branding/name', 'Bolt');
public set ( string $path, mixed $value ) : boolean
$path string
$value mixed
return boolean

setCKPath() public method

Deprecation: Deprecated since 3.3, to be removed in 4.0.
public setCKPath ( )

Property Details

$app protected_oe property

protected Application,Silex $app
return Silex\Application

$cachetimestamp protected_oe property

protected int $cachetimestamp
return integer

$data protected_oe property

protected array $data
return array

$defaultConfig protected_oe property

protected array $defaultConfig
return array

$fields public_oe property

Will be made protected in Bolt 3.0.
public Manager,Bolt\Storage\Field $fields
return Bolt\Storage\Field\Manager

$notify_update public_oe property

@deprecated Deprecated since 3.2, to be removed in 4.0
public bool $notify_update
return boolean

$reservedFieldNames protected_oe property

protected array $reservedFieldNames
return array

$yamlParser protected_oe property

protected Parser,Symfony\Component\Yaml $yamlParser
return Symfony\Component\Yaml\Parser