Configuration.php
1 <?php
2 /**
3  * wCMF - wemove Content Management Framework
4  * Copyright (C) 2005-2020 wemove digital solutions GmbH
5  *
6  * Licensed under the terms of the MIT License.
7  *
8  * See the LICENSE file distributed with this work for
9  * additional information.
10  */
11 namespace wcmf\lib\config;
12 
13 /**
14  * Implementations of Configuration give access to the application
15  * configuration. An instance of a Configuration implementation must
16  * be created on application startup and must be registered at ObjectFactory
17  * using the ObjectFactory::registerInstance() method.
18  *
19  * Configurations are supposed to be separated into sections, that contain
20  * keys with values. Section names and keys are treated case insensitive.
21  *
22  * There maybe more than one application configuration.
23  * You can retrieve their names by using the Configuration::getConfigurations()
24  * method. Different configurations maybe merged by calling the
25  * Configuration::addConfiguration() method. While merging, existing values
26  * will be overwritten, while new values will be added. This allows
27  * to have very flexible application configurations for different scenarios,
28  * users and roles.
29  *
30  * @author ingo herwig <ingo@wemove.com>
31  */
32 interface Configuration {
33 
34  /**
35  * Get a list of available configurations.
36  * @return Array of configuration names.
37  */
38  public function getConfigurations();
39 
40  /**
41  * Parses the given configuration and merges it with already added configurations.
42  * @param $name The name of the configuration
43  * @param $processValues Boolean whether values should be processed after parsing (e.g. make arrays) (default: _true_)
44  */
45  public function addConfiguration($name, $processValues=true);
46 
47  /**
48  * Get all section names.
49  * @return An array of section names.
50  */
51  public function getSections();
52 
53  /**
54  * Check if a section exists.
55  * @param $section The section to check for.
56  * @return Boolean
57  */
58  public function hasSection($section);
59 
60  /**
61  * Get a section.
62  * @param $section The section to return.
63  * @param $includeMeta Boolean whether to include section meta data keys (optional, default: false)
64  * @return Array holding the key/value pairs belonging to the section.
65  * @throws ConfigurationException if the section does not exist
66  */
67  public function getSection($section, $includeMeta=false);
68 
69  /**
70  * Check if a configuration value exists.
71  * @param $key The name of the value.
72  * @param $section The section the value belongs to.
73  * @return Boolean
74  */
75  public function hasValue($key, $section);
76 
77  /**
78  * Get a configuration value.
79  * @param $key The name of the entry.
80  * @param $section The section the key belongs to.
81  * @return The configuration value.
82  * @throws ConfigurationException if the value does not exist
83  */
84  public function getValue($key, $section);
85 
86  /**
87  * Get a value from the configuration as boolean if it represents a boolean.
88  * @param $key The name of the entry.
89  * @param $section The section the key belongs to.
90  * @return Boolean or the original value.
91  * @throws ConfigurationException if the value does not exist
92  */
93  public function getBooleanValue($key, $section);
94 
95  /**
96  * Get a directory value from the configuration.
97  * The value will interpreted as directory relative to WCMF_BASE and
98  * returned as absolute path.
99  * @param $key The name of the entry.
100  * @param $section The section the key belongs to.
101  * @return The configuration value.
102  * @throws ConfigurationException if the value does not exist
103  */
104  public function getDirectoryValue($key, $section);
105 
106  /**
107  * Get a file value from the configuration.
108  * The value will interpreted as file relative to WCMF_BASE and
109  * returned as absolute path.
110  * @param $key The name of the entry.
111  * @param $section The section the key belongs to.
112  * @return The configuration value.
113  * @throws ConfigurationException if the value does not exist
114  */
115  public function getFileValue($key, $section);
116 
117  /**
118  * Get a configuration key.
119  * @param $value The value of the entry.
120  * @param $section The section the value belongs to.
121  * @return The configuration key.
122  * @throws ConfigurationException if the key does not exist
123  */
124  public function getKey($value, $section);
125 }
126 ?>
getConfigurations()
Get a list of available configurations.
addConfiguration($name, $processValues=true)
Parses the given configuration and merges it with already added configurations.
getBooleanValue($key, $section)
Get a value from the configuration as boolean if it represents a boolean.
getValue($key, $section)
Get a configuration value.
Implementations of Configuration give access to the application configuration.
getSections()
Get all section names.
Configuration related interfaces and classes.
Definition: namespaces.php:6
getDirectoryValue($key, $section)
Get a directory value from the configuration.
getFileValue($key, $section)
Get a file value from the configuration.
getSection($section, $includeMeta=false)
Get a section.
getKey($value, $section)
Get a configuration key.
hasValue($key, $section)
Check if a configuration value exists.
hasSection($section)
Check if a section exists.