ConfigActionKeyProvider.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\impl;
12 
15 
16 /**
17  * ConfigActionKeyProvider searches for action keys in the
18  * application configuration.
19  *
20  * @author ingo herwig <ingo@wemove.com>
21  */
23 
24  private $configuration = null;
25  private $configSection = null;
26  private $id = null;
27 
28  /**
29  * Constructor
30  * @param $configuration Configuration instance
31  * @param $configSection The configuration section to search in
32  */
33  public function __construct(Configuration $configuration, $configSection) {
34  $this->configuration = $configuration;
35  $this->configSection = $configSection;
36  $this->id = null;
37  }
38 
39  /**
40  * @see ActionKeyProvider::containsKey()
41  */
42  public function containsKey($actionKey) {
43  return $this->configuration->hasValue($actionKey, $this->configSection);
44  }
45 
46  /**
47  * @see ActionKeyProvider::getKeyValue()
48  */
49  public function getKeyValue($actionKey) {
50  if ($this->containsKey($actionKey)) {
51  return $this->configuration->getValue($actionKey, $this->configSection);
52  }
53  return null;
54  }
55 
56  /**
57  * @see ActionKeyProvider::getId()
58  */
59  public function getId() {
60  if ($this->id == null) {
61  $this->id = str_replace('\\', '.', __CLASS__).'.'.$this->configSection;
62  }
63  return $this->id;
64  }
65 }
66 ?>
Implementations of Configuration give access to the application configuration.
Implementations of ActionKeyProvider search for action keys.
__construct(Configuration $configuration, $configSection)
Constructor.
ConfigActionKeyProvider searches for action keys in the application configuration.