|
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\Core\Utility\GeneralUtility; |
|
20
|
|
|
use TYPO3\CMS\Extbase\Configuration\ConfigurationManager; |
|
21
|
|
|
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface; |
|
22
|
|
|
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer; |
|
23
|
|
|
|
|
24
|
|
|
class ContentObjectService implements SingletonInterface |
|
25
|
|
|
{ |
|
26
|
|
|
use SelfInstantiateTrait; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* @param string $table |
|
30
|
|
|
* @param int $uid |
|
31
|
|
|
* @param string $extensionName |
|
32
|
|
|
* @param string $pluginName |
|
33
|
|
|
* @return array |
|
34
|
|
|
*/ |
|
35
|
|
|
public function getContentObjectSettings($table, $uid, $extensionName, $pluginName) |
|
36
|
|
|
{ |
|
37
|
|
|
if (empty($table) |
|
38
|
|
|
|| empty($uid) |
|
39
|
|
|
|| empty($extensionName) |
|
40
|
|
|
|| empty($pluginName) |
|
41
|
|
|
) { |
|
42
|
|
|
return []; |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
/** @var ConfigurationManager $configurationManager */ |
|
46
|
|
|
$configurationManager = Core::instantiate(ConfigurationManagerInterface::class); |
|
47
|
|
|
$contentObjectBackup = $configurationManager->getContentObject(); |
|
48
|
|
|
|
|
49
|
|
|
$database = Core::get()->getDatabase(); |
|
50
|
|
|
|
|
51
|
|
|
$content = $database->exec_SELECTgetSingleRow( |
|
52
|
|
|
'*', |
|
53
|
|
|
$database->quoteStr($table, $table), |
|
54
|
|
|
'uid=' . (int)$uid |
|
55
|
|
|
); |
|
56
|
|
|
|
|
57
|
|
|
/** @var ContentObjectRenderer $contentObject */ |
|
58
|
|
|
$contentObject = GeneralUtility::makeInstance(ContentObjectRenderer::class); |
|
59
|
|
|
$contentObject->start($content, $table); |
|
|
|
|
|
|
60
|
|
|
$configurationManager->setContentObject($contentObject); |
|
61
|
|
|
|
|
62
|
|
|
$configurationManager->setConfiguration([ |
|
63
|
|
|
'extensionName' => $extensionName, |
|
64
|
|
|
'pluginName' => $pluginName |
|
65
|
|
|
]); |
|
66
|
|
|
|
|
67
|
|
|
$configuration = $configurationManager->getConfiguration(ConfigurationManager::CONFIGURATION_TYPE_SETTINGS); |
|
68
|
|
|
|
|
69
|
|
|
$configurationManager->setContentObject($contentObjectBackup); |
|
70
|
|
|
|
|
71
|
|
|
return $configuration; |
|
72
|
|
|
} |
|
73
|
|
|
} |
|
74
|
|
|
|
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.