77use Exception ;
88use In2code \Femanager \Domain \Service \PluginService ;
99use In2code \Femanager \Utility \ObjectUtility ;
10+ use TYPO3 \CMS \Core \Context \Context ;
1011use PDO ;
12+ use TYPO3 \CMS \Core \Database \Query \Restriction \EndTimeRestriction ;
13+ use TYPO3 \CMS \Core \Database \Query \Restriction \HiddenRestriction ;
14+ use TYPO3 \CMS \Core \Database \Query \Restriction \StartTimeRestriction ;
1115use TYPO3 \CMS \Core \Service \FlexFormService ;
1216use TYPO3 \CMS \Core \Utility \GeneralUtility ;
1317
@@ -20,12 +24,16 @@ class PluginRepository
2024
2125 protected FlexFormService $ flexFormService ;
2226
27+ protected Context $ context ;
28+
2329 /**
30+ * @param Context|null $context
2431 * @param FlexFormService|null $flexFormService
2532 */
26- public function __construct (FlexFormService $ flexFormService = null )
33+ public function __construct (? Context $ context = null , ? FlexFormService $ flexFormService = null )
2734 {
2835 $ this ->flexFormService = $ flexFormService ?? GeneralUtility::makeInstance (FlexFormService::class);
36+ $ this ->context = $ context ?? GeneralUtility::makeInstance (Context::class);
2937 }
3038
3139 /**
@@ -39,7 +47,7 @@ public function isPluginWithViewOnGivenPage(int $pageIdentifier, string $pluginN
3947 if (in_array ($ pluginName , $ allowedPlugins )) {
4048 $ queryBuilder = ObjectUtility::getQueryBuilder (self ::TABLE_NAME );
4149 $ cType = str_replace ('tx_ ' , '' , $ pluginName );
42- $ pluginOnPageQuery = $ queryBuilder
50+ $ statement = $ queryBuilder
4351 ->select ('uid ' )
4452 ->from (self ::TABLE_NAME )
4553 ->where (
@@ -51,8 +59,18 @@ public function isPluginWithViewOnGivenPage(int $pageIdentifier, string $pluginN
5159 'CType ' ,
5260 $ queryBuilder ->createNamedParameter ($ cType , PDO ::PARAM_STR )
5361 )
54- )
55- ->executeQuery ();
62+ );
63+
64+ if ($ this ->context ->getPropertyFromAspect ('visibility ' , 'includeHiddenContent ' )) {
65+ $ statement
66+ ->getRestrictions ()
67+ ->removeByType (HiddenRestriction::class)
68+ ->removeByType (StartTimeRestriction::class)
69+ ->removeByType (EndTimeRestriction::class);
70+ }
71+
72+ $ pluginOnPageQuery = $ statement ->executeQuery ();
73+
5674 return count ($ pluginOnPageQuery ->fetchAllAssociative ()) > 0 ;
5775 }
5876
0 commit comments