ConfigParser

Parses configuration files

package

OCA\Gallery\Config

Methods

Constructor

__construct() 

Adds a config sub-section to the global config

addConfigItem(string $key, array $parsedConfigItem, integer $level) : \OCA\Gallery\Config\array<null|\OCA\Gallery\Config\array<string,string>,bool>

Arguments

$key

string

the configuration sub-section identifier

$parsedConfigItem

array

the configuration for a sub-section

$level

integer

the starting level is 0 and we add 1 each time we visit a parent folder

Response

\OCA\Gallery\Config\array,bool>

Removes the BOM from a file

bomFixer(string $file) : string

Arguments

$file

string

Response

string

Returns either the local config or one merged with a config containing sorting information

buildAlbumConfig(array $currentConfig, array $parsedConfig,  $completionStatus, integer $level) : array

Arguments

$currentConfig

array

the configuration collected so far

$parsedConfig

array

the configuration collected in the current folder

$completionStatus

$level

integer

the starting level is 0 and we add 1 each time we visit a parent folder

Response

array

<null|array,array<string,bool>>

Returns a parsed global configuration if one was found in the root folder

getFeaturesList(\OCP\Files\Folder $folder, string $configName) : null|array

Arguments

$folder

\OCP\Files\Folder

the current folder

$configName

string

name of the configuration file

Response

null|array

Returns a parsed configuration if one was found in the current folder

getFolderConfig(\OCP\Files\Folder $folder, string $configName, array $currentConfig,  $completionStatus, integer $level) : array
Throws
\OCA\Gallery\Config\ConfigException

Arguments

$folder

\OCP\Files\Folder

the current folder

$configName

string

name of the configuration file

$currentConfig

array

the configuration collected so far

$completionStatus

$level

integer

the starting level is 0 and we add 1 each time we visit a parent folder

Response

array

<null|array,array<string,bool>>

Determines if we can use a configuration sub-section found in parent folders

isConfigInheritable(array $parsedConfigItem) : boolean

Arguments

$parsedConfigItem

array

the configuration for a sub-section

Response

boolean

Determines if we already have everything we need for this configuration sub-section

isConfigItemComplete(string $key, array $parsedConfig, boolean $complete) : boolean

Arguments

$key

string

the configuration sub-section identifier

$parsedConfig

array

the configuration for that sub-section

$complete

boolean

Response

boolean

Determines if we can use this configuration sub-section

isConfigUsable(string $key, array $parsedConfigItem, integer $level) : boolean

It's possible in two cases:

  • the configuration was collected from the currently opened folder
  • the configuration was collected in a parent folder and is inheritable

We also need to make sure that the values contained in the configuration are safe for web use

Arguments

$key

string

the configuration sub-section identifier

$parsedConfigItem

array

the configuration for a sub-section

$level

integer

the starting level is 0 and we add 1 each time we visit a parent folder

Response

boolean

Returns a parsed configuration

parseConfig(\OCP\Files\Folder $folder, string $configName) : array
Throws
\OCA\Gallery\Config\ConfigException

Arguments

$folder

\OCP\Files\Folder

the current folder

$configName

string

Response

array

Returns only the features which have been enabled

parseFeatures( $featuresList) : array

Arguments

$featuresList

Response

array

Properties

configValidator

configValidator : \OCA\Gallery\Config\ConfigValidator