14
14
use Magento \Framework \Controller \Result \Redirect ;
15
15
use Magento \Framework \Exception \LocalizedException ;
16
16
use Magento \Framework \HTTP \PhpEnvironment \Request ;
17
+ use Psr \Log \LoggerInterface ;
17
18
18
19
class Post extends \Magento \Contact \Controller \Index
19
20
{
@@ -32,22 +33,30 @@ class Post extends \Magento\Contact\Controller\Index
32
33
*/
33
34
private $ mail ;
34
35
36
+ /**
37
+ * @var LoggerInterface
38
+ */
39
+ private $ logger ;
40
+
35
41
/**
36
42
* @param Context $context
37
43
* @param ConfigInterface $contactsConfig
38
44
* @param MailInterface $mail
39
45
* @param DataPersistorInterface $dataPersistor
46
+ * @param LoggerInterface $logger
40
47
*/
41
48
public function __construct (
42
49
Context $ context ,
43
50
ConfigInterface $ contactsConfig ,
44
51
MailInterface $ mail ,
45
- DataPersistorInterface $ dataPersistor
52
+ DataPersistorInterface $ dataPersistor ,
53
+ LoggerInterface $ logger = null
46
54
) {
47
55
parent ::__construct ($ context , $ contactsConfig );
48
56
$ this ->context = $ context ;
49
57
$ this ->mail = $ mail ;
50
58
$ this ->dataPersistor = $ dataPersistor ;
59
+ $ this ->logger = $ logger ?: \Magento \Framework \App \ObjectManager::getInstance ()->get (LoggerInterface::class);
51
60
}
52
61
53
62
/**
@@ -70,8 +79,9 @@ public function execute()
70
79
$ this ->messageManager ->addErrorMessage ($ e ->getMessage ());
71
80
$ this ->getDataPersistor ()->set ('contact_us ' , $ this ->getRequest ()->getParams ());
72
81
} catch (\Exception $ e ) {
82
+ $ this ->logger ->critical ($ e );
73
83
$ this ->messageManager ->addErrorMessage (
74
- __ ('We can \' t process your request right now. Sorry, that \' s all we know . ' )
84
+ __ ('An error occurred while processing your form. Please try again later . ' )
75
85
);
76
86
$ this ->getDataPersistor ()->set ('contact_us ' , $ this ->getRequest ()->getParams ());
77
87
}
0 commit comments