feedit/Classes/Hooks/StdWrapEditPanelHook.php
2022-12-29 09:22:43 +01:00

62 lines
No EOL
2.1 KiB
PHP

<?php
declare(strict_types=1);
namespace TYPO3\CMS\Feedit\Hooks;
use TYPO3\CMS\Adminpanel\Service\ConfigurationService;
use TYPO3\CMS\Adminpanel\Utility\StateUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Utility\DebuggerUtility;
use TYPO3\CMS\Feedit\FrontendEditPanel;
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
use TYPO3\CMS\Frontend\ContentObject\ContentObjectStdWrapHookInterface;
class StdWrapEditPanelHook implements ContentObjectStdWrapHookInterface
{
public function __construct()
{
}
public function stdWrapPreProcess($content, array $configuration, ContentObjectRenderer &$parentObject)
{
return $content;
}
public function stdWrapOverride($content, array $configuration, ContentObjectRenderer &$parentObject)
{
return $content;
}
public function stdWrapProcess($content, array $configuration, ContentObjectRenderer &$parentObject)
{
return $content;
}
public function stdWrapPostProcess($content, array $configuration, ContentObjectRenderer &$parentObject)
{
$configurationService = GeneralUtility::makeInstance(ConfigurationService::class);
$user = $this->getFrontendBackendUser();
if ($user && ($configuration['editPanel'] ?? false) && StateUtility::isOpen() && $configurationService->getConfigurationOption('edit', 'displayIcons')) {
[$table, $uid] = explode(':', $parentObject->currentRecord);
$allowedActions = $user->getAllowedEditActions($table, $configuration['editPanel.'] ?? [], $parentObject->data['pid']);
$frontendEditPanel = GeneralUtility::makeInstance(FrontendEditPanel::class, $parentObject);
return $frontendEditPanel->editPanel(
$content,
$configuration['editPanel.'] ?? [],
$parentObject->currentRecord,
$parentObject->data,
'tt_content',
$allowedActions
);
}
return $content;
}
protected function getFrontendBackendUser()
{
return $GLOBALS['BE_USER'];
}
}