5
5
namespace Netlogix \Nxerrorhandler \Command ;
6
6
7
7
use InvalidArgumentException ;
8
- use Netlogix \Nxerrorhandler \ErrorHandler \GeneralExceptionHandler ;
9
- use Netlogix \Nxerrorhandler \Exception \Exception ;
10
8
use Netlogix \Nxerrorhandler \Service \ConfigurationService ;
11
9
use Psr \Http \Message \ServerRequestInterface ;
10
+ use Psr \Log \LoggerAwareInterface ;
11
+ use Psr \Log \LoggerAwareTrait ;
12
12
use Symfony \Component \Console \Command \Command ;
13
13
use Symfony \Component \Console \Input \InputArgument ;
14
14
use Symfony \Component \Console \Input \InputInterface ;
22
22
use TYPO3 \CMS \Core \Site \SiteFinder ;
23
23
use TYPO3 \CMS \Core \Utility \GeneralUtility ;
24
24
25
- class GenerateErrorPagesCommand extends Command
25
+ class GenerateErrorPagesCommand extends Command implements LoggerAwareInterface
26
26
{
27
- private int | bool | null $ deploymentDate = null ;
27
+ use LoggerAwareTrait ;
28
28
29
- private ? GeneralExceptionHandler $ exceptionHandler = null ;
29
+ private int | bool | null $ deploymentDate = null ;
30
30
31
31
protected function configure ()
32
32
{
@@ -74,6 +74,10 @@ protected function execute(InputInterface $input, OutputInterface $output): int
74
74
GeneralUtility::setIndpEnv ('TYPO3_REQUEST_URL ' , (string ) $ site ->getBase ());
75
75
foreach ($ errorHandlingConfiguration as $ errorCode => $ configuration ) {
76
76
foreach ($ site ->getLanguages () as $ language ) {
77
+ if ($ language ->isEnabled () === false ) {
78
+ continue ;
79
+ }
80
+
77
81
if (!$ forceGeneration && !$ this ->checkIfErrorPageNeedsRegeneration ($ errorCode , $ site , $ language )) {
78
82
continue ;
79
83
}
@@ -87,15 +91,13 @@ protected function execute(InputInterface $input, OutputInterface $output): int
87
91
$ resolvedUrl = $ this ->resolveUrl ($ request , $ configuration ['errorContentSource ' ]);
88
92
$ content = GeneralUtility::getUrl ($ resolvedUrl );
89
93
if ($ content === false || $ content === '' ) {
90
- $ message = sprintf (
94
+ $ this -> logger -> error ( sprintf (
91
95
'Could not retrieve [%1$s] error page on rootPageId [%2$d] with language [%3$d]. Requested url was "%4$s". ' ,
92
96
$ errorCode ,
93
97
$ site ->getRootPageId (),
94
98
$ language ->getLanguageId (),
95
99
$ resolvedUrl
96
- );
97
- $ this ->getExceptionHandler ()
98
- ->logError (new \Exception ($ message , 1395152041 ), GeneralExceptionHandler::CONTEXT_CLI );
100
+ ));
99
101
100
102
continue ;
101
103
}
@@ -113,7 +115,7 @@ private function initializeTargetDirectory(): void
113
115
if (!file_exists (ConfigurationService::getErrorDocumentDirectory ())) {
114
116
GeneralUtility::mkdir (ConfigurationService::getErrorDocumentDirectory ());
115
117
} elseif (!is_dir (ConfigurationService::getErrorDocumentDirectory ())) {
116
- throw new Exception ('Target directory is not a directory ' , 1394124945 );
118
+ throw new \ RuntimeException ('Target directory is not a directory ' , 1394124945 );
117
119
}
118
120
}
119
121
@@ -127,15 +129,6 @@ protected function saveErrorPage(int $errorCode, Site $site, SiteLanguage $langu
127
129
GeneralUtility::writeFile ($ file , $ content );
128
130
}
129
131
130
- private function getExceptionHandler (): GeneralExceptionHandler
131
- {
132
- if (!$ this ->exceptionHandler instanceof GeneralExceptionHandler) {
133
- $ this ->exceptionHandler = GeneralUtility::makeInstance (GeneralExceptionHandler::class);
134
- }
135
-
136
- return $ this ->exceptionHandler ;
137
- }
138
-
139
132
private function checkIfErrorPageNeedsRegeneration (int $ errorCode , Site $ site , SiteLanguage $ language ): bool
140
133
{
141
134
$ file = $ this ->getErrorDocumentFilePath ($ errorCode , $ site , $ language );
0 commit comments