Skip to content
This repository was archived by the owner on Aug 15, 2023. It is now read-only.

Commit 07a81e0

Browse files
committed
[FEATURE] implement ConfigurationApiService
1 parent e2140b2 commit 07a81e0

File tree

2 files changed

+54
-8
lines changed

2 files changed

+54
-8
lines changed

Classes/Command/ConfigurationApiCommandController.php

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
***************************************************************/
2626

2727
use TYPO3\CMS\Extbase\Mvc\Controller\CommandController;
28-
use TYPO3\CMS\Extbase\Reflection\ObjectAccess;
2928

3029
/**
3130
* Configuration API Command Controller
@@ -36,23 +35,27 @@
3635
class ConfigurationApiCommandController extends CommandController {
3736

3837
/**
39-
* listCommand
38+
* @var \Etobi\CoreAPI\Service\ConfigurationApiService
39+
* @inject
40+
*/
41+
protected $configurationApiService;
42+
43+
/**
44+
* List all configurations
4045
*
4146
* @return string
4247
*/
4348
public function listCommand() {
44-
$typo3ConfVars = $GLOBALS['TYPO3_CONF_VARS'];
45-
$this->outputLine(json_encode($typo3ConfVars));
49+
$this->outputLine(json_encode($this->configurationApiService->getConfigurationArray()));
4650
}
4751

4852
/**
49-
* showCommand
53+
* Get configuration value for given key
5054
*
51-
* @param string $param
55+
* @param string $key
5256
* @return string
5357
*/
5458
public function showCommand($key) {
55-
$typo3ConfVars = ObjectAccess::getPropertyPath($GLOBALS['TYPO3_CONF_VARS'], $key);
56-
$this->outputLine(json_encode($typo3ConfVars));
59+
$this->outputLine(json_encode($this->configurationApiService->getValue($key)));
5760
}
5861
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
namespace Etobi\CoreAPI\Service;
3+
4+
/**
5+
* This file is part of the TYPO3 CMS project.
6+
*
7+
* It is free software; you can redistribute it and/or modify it under
8+
* the terms of the GNU General Public License, either version 2
9+
* of the License, or any later version.
10+
*
11+
* For the full copyright and license information, please read the
12+
* LICENSE.txt file that was distributed with this source code.
13+
*
14+
* The TYPO3 project - inspiring people to share!
15+
*/
16+
use TYPO3\CMS\Core\Utility\GeneralUtility;
17+
use TYPO3\CMS\Extbase\Reflection\ObjectAccess;
18+
19+
/**
20+
* Site API service
21+
*
22+
* @author Tobias Liebig <[email protected]>
23+
* @package Etobi\CoreAPI\Service\ConfigurationApiService
24+
*/
25+
class ConfigurationApiService {
26+
27+
/**
28+
* @param string $key
29+
* @return mixed
30+
*/
31+
public function getValue($key) {
32+
return ObjectAccess::getPropertyPath($this->getConfigurationArray(), $key);
33+
}
34+
35+
/**
36+
* Returns the configuration array
37+
*
38+
* @return array
39+
*/
40+
public function getConfigurationArray() {
41+
return $GLOBALS['TYPO3_CONF_VARS'];
42+
}
43+
}

0 commit comments

Comments
 (0)