1 <?php
2 /* --------------------------------------------------------------
3 UserConfigurationReader.inc.php 2015-10-05 gm
4 Gambio GmbH
5 http://www.gambio.de
6 Copyright (c) 2015 Gambio GmbH
7 Released under the GNU General Public License (Version 2)
8 [http://www.gnu.org/licenses/gpl-2.0.html]
9 --------------------------------------------------------------
10 */
11
12 /**
13 * Class UserConfigurationReader
14 *
15 * @category System
16 * @package UserConfiguration
17 * @subpackage Repository
18 */
19 class UserConfigurationReader implements UserConfigurationReaderInterface
20 {
21 /**
22 * @var CI_DB_query_builder
23 */
24 protected $db;
25
26
27 public function __construct(CI_DB_query_builder $db)
28 {
29 $this->db = $db;
30 }
31
32
33 /**
34 * @override
35 */
36 public function getUserConfiguration(IdType $userId, $configurationKey)
37 {
38 $result = $this->db->select('configuration_value')
39 ->from('user_configuration')
40 ->where(array('customer_id' => (string)$userId, 'configuration_key' => $configurationKey))
41 ->get()
42 ->row_array(0);
43
44 return !is_null($result) ? $result['configuration_value'] : null;
45 }
46 }