ConfigListStrategy.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  */
12 
16 
17 /**
18  * ConfigListStrategy implements a list of key/value pairs that is retrieved
19  * from a configuration section.
20  *
21  * Configuration example:
22  * @code
23  * // configuration section EntityStage
24  * {"type":"config","section":"EntityStage"}
25  * @endcode
26  *
27  * @author ingo herwig <ingo@wemove.com>
28  */
29 class ConfigListStrategy implements ListStrategy {
30 
31  private $_lists = array();
32 
33  /**
34  * @see ListStrategy::getList
35  * $options is an associative array with key 'section'
36  */
37  public function getList($options, $language=null) {
38  if (!isset($options['section'])) {
39  throw new ConfigurationException("No 'pattern' given in list options: "+$options);
40  }
41  $section = $options['section'];
42  $listKey = $section.$language;
43  if (!isset($this->_lists[$listKey])) {
44  $config = ObjectFactory::getInstance('configuration');
45  $map = $config->getSection($section);
46  $result = array();
48  foreach ($map as $key => $value) {
49  $result[$key] = $message->getText($value, null, $language);
50  }
51  $this->_lists[$listKey] = $result;
52  }
53  return $this->_lists[$listKey];
54  }
55 
56  /**
57  * @see ListStrategy::isStatic
58  */
59  public function isStatic($options) {
60  return true;
61  }
62 }
63 ?>
static getInstance($name, $dynamicConfiguration=array())
$message
Predefined errors.
ConfigListStrategy implements a list of key/value pairs that is retrieved from a configuration sectio...
ListStrategy defines the interface for classes that retrieve value lists.
ConfigurationException signals an exception in the configuration.