|
1
|
|
|
<?php |
|
2
|
|
|
/* |
|
3
|
|
|
* 2017 Romain CANON <[email protected]> |
|
4
|
|
|
* |
|
5
|
|
|
* This file is part of the TYPO3 FormZ project. |
|
6
|
|
|
* It is free software; you can redistribute it and/or modify it |
|
7
|
|
|
* under the terms of the GNU General Public License, either |
|
8
|
|
|
* version 3 of the License, or any later version. |
|
9
|
|
|
* |
|
10
|
|
|
* For the full copyright and license information, see: |
|
11
|
|
|
* http://www.gnu.org/licenses/gpl-3.0.html |
|
12
|
|
|
*/ |
|
13
|
|
|
|
|
14
|
|
|
namespace Romm\Formz\Service; |
|
15
|
|
|
|
|
16
|
|
|
use Romm\Formz\Core\Core; |
|
17
|
|
|
use Romm\Formz\Service\Traits\SelfInstantiateTrait; |
|
18
|
|
|
use TYPO3\CMS\Core\SingletonInterface; |
|
19
|
|
|
use TYPO3\CMS\Extbase\Configuration\ConfigurationManager; |
|
20
|
|
|
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer; |
|
21
|
|
|
|
|
22
|
|
|
class ContentObjectService implements SingletonInterface |
|
23
|
|
|
{ |
|
24
|
|
|
use SelfInstantiateTrait; |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* @param string $table |
|
28
|
|
|
* @param int $uid |
|
29
|
|
|
* @param string $extensionName |
|
30
|
|
|
* @param string $pluginName |
|
31
|
|
|
* @return array |
|
32
|
|
|
*/ |
|
33
|
|
|
public function getContentObjectSettings($table, $uid, $extensionName, $pluginName) |
|
34
|
|
|
{ |
|
35
|
|
|
/** @var ConfigurationManager $configurationManager */ |
|
36
|
|
|
$configurationManager = Core::instantiate(ConfigurationManager::class); |
|
37
|
|
|
|
|
38
|
|
|
$contentObjectBackup = $configurationManager->getContentObject(); |
|
39
|
|
|
|
|
40
|
|
|
$content = Core::get()->getDatabase()->exec_SELECTgetSingleRow('*', $table,'uid=' . $uid); |
|
41
|
|
|
|
|
42
|
|
|
$contentObject = new ContentObjectRenderer; |
|
43
|
|
|
$contentObject->start($content, $table); |
|
|
|
|
|
|
44
|
|
|
$configurationManager->setContentObject($contentObject); |
|
45
|
|
|
|
|
46
|
|
|
$configurationManager->setConfiguration([ |
|
47
|
|
|
'extensionName' => $extensionName, |
|
48
|
|
|
'pluginName' => $pluginName |
|
49
|
|
|
]); |
|
50
|
|
|
|
|
51
|
|
|
$configuration = $configurationManager->getConfiguration(ConfigurationManager::CONFIGURATION_TYPE_SETTINGS); |
|
52
|
|
|
|
|
53
|
|
|
$configurationManager->setContentObject($contentObjectBackup); |
|
54
|
|
|
|
|
55
|
|
|
return $configuration; |
|
56
|
|
|
} |
|
57
|
|
|
} |
|
58
|
|
|
|
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.