-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* [WIP] Change t3 require verstion * [BUGFIX] TYPO3_MODE * [TASK] rector fix * [WIP] Change array indexes to assoc values * [WIP] Drop support for api v1, v2, add v3 * [BUGFIX] Select item in backend * [TASK] Set up tests * [TASK] Fix rendering * [TASK] Fix BackendPreview * [TASK] Fix test * [BUGFIX] Select external icons in plugin * [TASK] major version up * [TASK] Change ci github * [TASK] Update dev dependencies --------- Co-authored-by: Rafal Jania <[email protected]>
- Loading branch information
Showing
24 changed files
with
176 additions
and
302 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
Todos.md | ||
.php_cs.cache | ||
/Documentation-GENERATED-temp | ||
.build/ | ||
Build/.phpunit.result.cache | ||
composer.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
Classes/Backend/EventListener/BackendPreviewEventListener.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace StudioMitte\Riddle\Backend\EventListener; | ||
|
||
use TYPO3\CMS\Backend\View\Event\PageContentPreviewRenderingEvent; | ||
use TYPO3\CMS\Core\Attribute\AsEventListener; | ||
use StudioMitte\Riddle\Api\RiddleApi; | ||
use StudioMitte\Riddle\Exception\ApiConfigurationMissingException; | ||
use StudioMitte\Riddle\Utility\RiddleUtility; | ||
use TYPO3\CMS\Core\Utility\GeneralUtility; | ||
use TYPO3\CMS\Fluid\View\StandaloneView; | ||
|
||
#[AsEventListener( | ||
identifier: 'riddle/riddle' | ||
)] | ||
final class BackendPreviewEventListener | ||
{ | ||
/** @var string */ | ||
private $template = 'EXT:riddle/Resources/Private/Templates/BackendPreview.html'; | ||
|
||
public function __invoke(PageContentPreviewRenderingEvent $event): void | ||
{ | ||
if ($event->getTable() !== 'tt_content') { | ||
return; | ||
} | ||
|
||
if ($event->getRecord()['CType'] === 'list' && $event->getRecord()['list_type'] === 'riddle_riddle') { | ||
$riddleId = RiddleUtility::getRiddleId($event->getRecord()['pi_flexform']); | ||
|
||
$standaloneView = $this->getView(); | ||
try { | ||
$standaloneView->assignMultiple([ | ||
'riddleId' => $riddleId, | ||
'riddle' => $this->getRiddleData($riddleId), | ||
]); | ||
} catch (ApiConfigurationMissingException $exception) { | ||
$standaloneView->assign('apiNotConfigured', true); | ||
} | ||
|
||
$event->setPreviewContent($standaloneView->render()); | ||
} | ||
} | ||
|
||
protected function getView(): StandaloneView | ||
{ | ||
$standaloneView = GeneralUtility::makeInstance(StandaloneView::class); | ||
$standaloneView->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName($this->template)); | ||
$standaloneView->assignMultiple([ | ||
'dateTime' => $GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'] . ' ' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['hhmm'], | ||
'lll' => 'LLL:EXT:riddle/Resources/Private/Language/locallang.xlf:', | ||
]); | ||
return $standaloneView; | ||
} | ||
|
||
/** | ||
* @param string|int $id | ||
* @return array | ||
*/ | ||
protected function getRiddleData($id): array | ||
{ | ||
$api = GeneralUtility::makeInstance(RiddleApi::class); | ||
$item = $api->getRiddleItem($id); | ||
return RiddleUtility::enrichRiddleData($item); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.