55namespace IchHabRecht \SocialGdpr \Form \CustomInlineControl ;
66
77use IchHabRecht \SocialGdpr \Service \PreviewImageServiceRegistry ;
8- use TYPO3 \CMS \Backend \Form \Element \InlineElementHookInterface ;
98use TYPO3 \CMS \Backend \Form \Event \ModifyFileReferenceControlsEvent ;
9+ use TYPO3 \CMS \Backend \Form \Event \ModifyInlineElementControlsEvent ;
10+ use TYPO3 \CMS \Backend \Form \Event \ModifyInlineElementEnabledControlsEvent ;
11+ use TYPO3 \CMS \Core \Attribute \AsEventListener ;
1012use TYPO3 \CMS \Core \Imaging \Icon ;
1113use TYPO3 \CMS \Core \Imaging \IconFactory ;
1214use TYPO3 \CMS \Core \Imaging \IconRegistry ;
1517use TYPO3 \CMS \Core \Resource \ResourceFactory ;
1618use TYPO3 \CMS \Core \Utility \GeneralUtility ;
1719
18- class OnlineFalMediaPreviewFlush implements InlineElementHookInterface
20+
21+ #[AsEventListener(
22+ identifier: 'socialgdprModifyFileReferenceControlsEvent ' ,
23+ event: ModifyFileReferenceControlsEvent::class,
24+ method: 'renderFileReferenceHeaderControl ' ,
25+ )]
26+ #[AsEventListener(
27+ identifier: 'socialgdprModifyInlineElementControlsEvent ' ,
28+ event: ModifyInlineElementControlsEvent::class,
29+ method: 'modifyControls ' ,
30+ )]
31+ class OnlineFalMediaPreviewFlushEventListener
1932{
2033 protected IconFactory $ iconFactory ;
2134
@@ -30,12 +43,12 @@ class OnlineFalMediaPreviewFlush implements InlineElementHookInterface
3043 protected ResourceFactory $ resourceFactory ;
3144
3245 public function __construct (
33- IconFactory $ iconFactory = null ,
34- IconRegistry $ iconRegistry = null ,
35- OnlineMediaHelperRegistry $ onlineMediaRegistry = null ,
36- PageRenderer $ pageRenderer = null ,
37- PreviewImageServiceRegistry $ previewImageServiceRegistry = null ,
38- ResourceFactory $ resourceFactory = null
46+ ? IconFactory $ iconFactory = null ,
47+ ? IconRegistry $ iconRegistry = null ,
48+ ? OnlineMediaHelperRegistry $ onlineMediaRegistry = null ,
49+ ? PageRenderer $ pageRenderer = null ,
50+ ? PreviewImageServiceRegistry $ previewImageServiceRegistry = null ,
51+ ? ResourceFactory $ resourceFactory = null
3952 ) {
4053 $ this ->iconFactory = $ iconFactory ?: GeneralUtility::makeInstance (IconFactory::class);
4154 $ this ->iconRegistry = $ iconRegistry ?: GeneralUtility::makeInstance (IconRegistry::class);
@@ -45,7 +58,7 @@ public function __construct(
4558 $ this ->resourceFactory = $ resourceFactory ?: GeneralUtility::makeInstance (ResourceFactory::class);
4659 }
4760
48- public function renderFileReferenceHeaderControl (ModifyFileReferenceControlsEvent $ event )
61+ public function renderFileReferenceHeaderControl (ModifyFileReferenceControlsEvent $ event ): void
4962 {
5063 $ elementData = $ event ->getElementData ();
5164 if ($ elementData ['tableName ' ] !== 'sys_file_reference ' ) {
@@ -61,32 +74,15 @@ public function renderFileReferenceHeaderControl(ModifyFileReferenceControlsEven
6174 return ;
6275 }
6376
64- $ this ->pageRenderer ->loadRequireJsModule ( ' TYPO3/CMS/SocialGdpr/ Backend/PreviewImageFlush ' );
77+ $ this ->pageRenderer ->loadJavaScriptModule ( ' @vendor/social_gdpr/ Backend/PreviewImageFlush.js ' );
6578 $ controls = $ event ->getControls ();
6679 $ controls ['youtubeFlush ' ] = $ this ->renderControlItem ($ record );
6780 $ event ->setControls ($ controls );
6881 }
6982
70- public function renderForeignRecordHeaderControl_preProcess (
71- $ parentUid ,
72- $ foreignTable ,
73- array $ childRecord ,
74- array $ childConfig ,
75- $ isVirtual ,
76- array &$ enabledControls
77- ) {
78- // Do nothing.
79- }
80-
81- public function renderForeignRecordHeaderControl_postProcess (
82- $ parentUid ,
83- $ foreignTable ,
84- array $ childRecord ,
85- array $ childConfig ,
86- $ isVirtual ,
87- array &$ controlItems
88- ) {
89- if ($ foreignTable !== 'sys_file_reference ' ) {
83+ public function modifyControls (ModifyInlineElementControlsEvent $ event ): void
84+ {
85+ if ($ event ->getElementData ()['inlineParentTableName ' ] !== 'sys_file_reference ' ) {
9086 return ;
9187 }
9288
@@ -98,8 +94,9 @@ public function renderForeignRecordHeaderControl_postProcess(
9894 return ;
9995 }
10096
101- $ this ->pageRenderer ->loadRequireJsModule ( ' TYPO3/CMS/SocialGdpr/ Backend/PreviewImageFlush ' );
97+ $ this ->pageRenderer ->loadJavaScriptModule ( ' @vendor/social_gdpr/ Backend/PreviewImageFlush.js ' );
10298 $ controlItems ['youtubeFlush ' ] = $ this ->renderControlItem ($ childRecord );
99+ $ event ->setControls ($ controlItems );
103100 }
104101
105102 protected function renderControlItem (array $ record ): string
0 commit comments