33namespace Gdatacyberdefenseag \GdataAntivirus \Vaas ;
44
55use Gdatacyberdefenseag \GdataAntivirus \Infrastructure \FileSystem \IGdataAntivirusFileSystem ;
6+ use Gdatacyberdefenseag \GdataAntivirus \PluginPage \AdminNotices ;
67use Psr \Log \LoggerInterface ;
78use VaasSdk \Vaas ;
89use VaasSdk \Authentication \ClientCredentialsGrantAuthenticator ;
@@ -16,14 +17,27 @@ class ScanClient {
1617 private LoggerInterface $ logger ;
1718 private VaasOptions $ vaas_options ;
1819 private IGdataAntivirusFileSystem $ file_system ;
19-
20- public function __construct ( LoggerInterface $ logger , VaasOptions $ vaas_options , IGdataAntivirusFileSystem $ file_system ) {
20+ private AdminNotices $ admin_notices ;
21+
22+ public function __construct (
23+ LoggerInterface $ logger ,
24+ VaasOptions $ vaas_options ,
25+ IGdataAntivirusFileSystem $ file_system ,
26+ AdminNotices $ admin_notices
27+ ) {
2128 $ logger ->info ('ScanClient::__construct ' );
2229 $ this ->logger = $ logger ;
2330 $ this ->vaas_options = $ vaas_options ;
2431 $ this ->file_system = $ file_system ;
32+ $ this ->admin_notices = $ admin_notices ;
2533
26- $ this ->Connect ();
34+ try {
35+ $ this ->Connect ();
36+ } catch (\Exception $ e ) {
37+ $ this ->admin_notices ->add_notice ($ e ->getMessage ());
38+ $ this ->logger ->error ("VaaS connection failed. Please verify if the VaaS-Url is correct. " );
39+ return ;
40+ }
2741 $ plugin_upload_scan_enabled = (bool ) \get_option ('gdatacyberdefenseag_antivirus_options_on_demand_scan_plugin_upload_scan_enabled ' , false );
2842 $ media_upload_scan_enabled = (bool ) \get_option ('gdatacyberdefenseag_antivirus_options_on_demand_scan_media_upload_scan_enabled ' , false );
2943 // We don't need to add the filters if both plugin and media upload scan are disabled.
0 commit comments