Skip to content

Commit

Permalink
[TASK] Extract getFlexFormData() to AbstractPluginPreviewRenderer
Browse files Browse the repository at this point in the history
  • Loading branch information
derhansen committed Jul 5, 2024
1 parent 58ee802 commit 6c6267d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
12 changes: 12 additions & 0 deletions Classes/Preview/AbstractPluginPreviewRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,18 @@ protected function getPluginName(array $record): string
return htmlspecialchars($this->getLanguageService()->sL(self::LLPATH . 'plugin.' . $pluginId . '.title'));
}

/**
* Returns the records flexform as array
*/
protected function getFlexFormData(string $flexform): array
{
$flexFormData = GeneralUtility::xml2array($flexform);
if (!is_array($flexFormData)) {
$flexFormData = [];
}
return $flexFormData;
}

/**
* Renders the given data and action as HTML table for plugin preview
*/
Expand Down
6 changes: 1 addition & 5 deletions Classes/Preview/PieventPreviewRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,7 @@ public function renderPageModulePreviewContent(GridColumnItem $item): string
{
$data = [];
$record = $item->getRecord();
$flexFormData = GeneralUtility::xml2array($record['pi_flexform']);
if (!is_array($flexFormData)) {
$flexFormData = [];
}

$flexFormData = $this->getFlexFormData($record['pi_flexform']);
$pluginName = $this->getPluginName($record);

$this->setPluginPidConfig($data, $flexFormData, 'listPid', 'additional');
Expand Down
7 changes: 1 addition & 6 deletions Classes/Preview/PiuserregPreviewRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,14 @@
namespace DERHANSEN\SfEventMgt\Preview;

use TYPO3\CMS\Backend\View\BackendLayout\Grid\GridColumnItem;
use TYPO3\CMS\Core\Utility\GeneralUtility;

class PiuserregPreviewRenderer extends AbstractPluginPreviewRenderer
{
public function renderPageModulePreviewContent(GridColumnItem $item): string
{
$data = [];
$record = $item->getRecord();
$flexFormData = GeneralUtility::xml2array($record['pi_flexform']);
if (!is_array($flexFormData)) {
$flexFormData = [];
}

$flexFormData = $this->getFlexFormData($record['pi_flexform']);
$pluginName = $this->getPluginName($record);

$this->setPluginPidConfig($data, $flexFormData, 'registrationPid', 'sDEF');
Expand Down

0 comments on commit 6c6267d

Please sign in to comment.