YamlReader
in package
Uses
MergeRecursiveTrait
VuFind YAML Configuration Reader
Tags
Table of Contents
- $cacheManager : Manager
- Cache manager
- $cacheName : string
- Cache directory name
- $files : array<string|int, mixed>
- Cache of loaded files.
- $pathResolver : PathResolver
- Config file path resolver
- __construct() : mixed
- Constructor
- get() : array<string|int, mixed>
- Return a configuration
- getArrayElemRefByPath() : mixed
- Return array element reference by path
- getFromPaths() : array<string|int, mixed>
- Given core and local filenames, retrieve the configuration data.
- isStringKeyedArray() : bool
- Determine if a variable is a string-keyed array
- mergeRecursive() : array<string|int, mixed>|string
- Merge array recursive without combining single values to a new array as php's array_merge_recursive function does.
- parseYaml() : array<string|int, mixed>
- Process a YAML file (and its parent, if necessary).
Properties
$cacheManager
Cache manager
protected
Manager
$cacheManager
$cacheName
Cache directory name
protected
string
$cacheName
= 'yaml'
$files
Cache of loaded files.
protected
array<string|int, mixed>
$files
= []
$pathResolver
Config file path resolver
protected
PathResolver
$pathResolver
Methods
__construct()
Constructor
public
__construct([Manager $cacheManager = null ][, PathResolver $pathResolver = null ]) : mixed
Parameters
- $cacheManager : Manager = null
-
Cache manager (optional)
- $pathResolver : PathResolver = null
-
Config file path resolver (optional; defaults to \VuFind\Config\Locator)
Return values
mixed —get()
Return a configuration
public
get(string $filename[, bool $useLocalConfig = true ][, bool $forceReload = false ]) : array<string|int, mixed>
Parameters
- $filename : string
-
Config file name
- $useLocalConfig : bool = true
-
Use local configuration if available
- $forceReload : bool = false
-
Reload even if config has been internally cached in the class.
Return values
array<string|int, mixed> —getArrayElemRefByPath()
Return array element reference by path
protected
& getArrayElemRefByPath(array<string|int, mixed> &$arr, array<string|int, mixed> $path[, bool $create = false ]) : mixed
Parameters
- $arr : array<string|int, mixed>
-
Array to access
- $path : array<string|int, mixed>
-
Path to retrieve
- $create : bool = false
-
Whether to create the path if it doesn't exist. Default is false.
Return values
mixed —getFromPaths()
Given core and local filenames, retrieve the configuration data.
protected
getFromPaths(string $defaultFile[, string $customFile = null ]) : array<string|int, mixed>
Parameters
- $defaultFile : string
-
Full path to file containing default YAML
- $customFile : string = null
-
Full path to file containing local customizations (may be null if no local file exists).
Return values
array<string|int, mixed> —isStringKeyedArray()
Determine if a variable is a string-keyed array
protected
isStringKeyedArray(mixed $op) : bool
Parameters
- $op : mixed
-
Variable to test
Return values
bool —mergeRecursive()
Merge array recursive without combining single values to a new array as php's array_merge_recursive function does.
protected
mergeRecursive(array<string|int, mixed>|string $val1, array<string|int, mixed>|string $val2) : array<string|int, mixed>|string
Parameters
- $val1 : array<string|int, mixed>|string
-
First Value
- $val2 : array<string|int, mixed>|string
-
Second Value
Return values
array<string|int, mixed>|string —merged values
parseYaml()
Process a YAML file (and its parent, if necessary).
protected
parseYaml(string $file[, string $defaultParent = null ]) : array<string|int, mixed>
Parameters
- $file : string
-
YAML file to load (will evaluate to null if file does not exist).
- $defaultParent : string = null
-
Parent YAML file from which $file should inherit (unless overridden by a specific directive in $file). None by default.