Configuration.php
1 <?php
2 /**
3  * wCMF - wemove Content Management Framework
4  * Copyright (C) 2005-2015 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  * @return Array holding the key/value pairs belonging to the section.
64  * @throws ConfigurationException if the section does not exist
65  */
66  public function getSection($section);
67 
68  /**
69  * Check if a configuration value exists.
70  * @param $key The name of the value.
71  * @param $section The section the value belongs to.
72  * @return Boolean
73  */
74  public function hasValue($key, $section);
75 
76  /**
77  * Get a configuration value.
78  * @param $key The name of the entry.
79  * @param $section The section the key belongs to.
80  * @return The configuration value.
81  * @throws ConfigurationException if the value does not exist
82  */
83  public function getValue($key, $section);
84 
85  /**
86  * Get a value from the configuration as boolean if it represents a boolean.
87  * @param $key The name of the entry.
88  * @param $section The section the key belongs to.
89  * @return Boolean or the original value.
90  * @throws ConfigurationException if the value does not exist
91  */
92  public function getBooleanValue($key, $section);
93 
94  /**
95  * Get a directory value from the configuration.
96  * The value will interpreted as directory relative to WCMF_BASE and
97  * returned as absolute path.
98  * @param $key The name of the entry.
99  * @param $section The section the key belongs to.
100  * @return The configuration value.
101  * @throws ConfigurationException if the value does not exist
102  */
103  public function getDirectoryValue($key, $section);
104 
105  /**
106  * Get a file value from the configuration.
107  * The value will interpreted as file relative to WCMF_BASE and
108  * returned as absolute path.
109  * @param $key The name of the entry.
110  * @param $section The section the key belongs to.
111  * @return The configuration value.
112  * @throws ConfigurationException if the value does not exist
113  */
114  public function getFileValue($key, $section);
115 
116  /**
117  * Get a configuration key.
118  * @param $value The value of the entry.
119  * @param $section The section the value belongs to.
120  * @return The configuration key.
121  * @throws ConfigurationException if the key does not exist
122  */
123  public function getKey($value, $section);
124 }
125 ?>
getKey($value, $section)
Get a configuration key.
getBooleanValue($key, $section)
Get a value from the configuration as boolean if it represents a boolean.
getConfigurations()
Get a list of available configurations.
hasSection($section)
Check if a section exists.
addConfiguration($name, $processValues=true)
Parses the given configuration and merges it with already added configurations.
getValue($key, $section)
Get a configuration value.
getFileValue($key, $section)
Get a file value from the configuration.
Configuration related interfaces and classes.
Definition: namespaces.php:6
getDirectoryValue($key, $section)
Get a directory value from the configuration.
getSection($section)
Get a section.
getSections()
Get all section names.
Implementations of Configuration give access to the application configuration.
hasValue($key, $section)
Check if a configuration value exists.