1 | <?php |
||||||||||
2 | /** |
||||||||||
3 | * Copyright (c) 2019. Volodymyr Hryvinskyi. All rights reserved. |
||||||||||
4 | * @author: <mailto:[email protected]> |
||||||||||
5 | * @github: <https://github.com/hryvinskyi> |
||||||||||
6 | */ |
||||||||||
7 | |||||||||||
8 | declare(strict_types=1); |
||||||||||
9 | |||||||||||
10 | namespace Hryvinskyi\InvisibleCaptcha\Model\Provider\Failure; |
||||||||||
11 | |||||||||||
12 | use Hryvinskyi\InvisibleCaptcha\Helper\Config\General; |
||||||||||
13 | use Hryvinskyi\InvisibleCaptcha\Model\Provider\AbstractFailure; |
||||||||||
14 | use Hryvinskyi\InvisibleCaptcha\Model\Provider\FailureMessages; |
||||||||||
15 | use Hryvinskyi\InvisibleCaptcha\Model\ReCaptcha\Response; |
||||||||||
16 | use Magento\Framework\App\Action\Action; |
||||||||||
17 | use Magento\Framework\App\ActionFlag; |
||||||||||
18 | use Magento\Framework\App\Request\Http; |
||||||||||
19 | use Magento\Framework\App\ResponseInterface; |
||||||||||
20 | use Magento\Framework\Json\EncoderInterface; |
||||||||||
21 | |||||||||||
22 | class AjaxResponseFailure extends AbstractFailure |
||||||||||
23 | { |
||||||||||
24 | /** |
||||||||||
25 | * @var ActionFlag |
||||||||||
26 | */ |
||||||||||
27 | private $actionFlag; |
||||||||||
28 | |||||||||||
29 | /** |
||||||||||
30 | * @var EncoderInterface |
||||||||||
31 | */ |
||||||||||
32 | private $encoder; |
||||||||||
33 | |||||||||||
34 | /** |
||||||||||
35 | * @var General |
||||||||||
36 | */ |
||||||||||
37 | private $config; |
||||||||||
38 | |||||||||||
39 | /** |
||||||||||
40 | * AjaxResponseFailure constructor. |
||||||||||
41 | * |
||||||||||
42 | * @param ActionFlag $actionFlag |
||||||||||
43 | * @param EncoderInterface $encoder |
||||||||||
44 | * @param General $config |
||||||||||
45 | * @param FailureMessages $failureMessages |
||||||||||
46 | */ |
||||||||||
47 | public function __construct( |
||||||||||
48 | ActionFlag $actionFlag, |
||||||||||
49 | EncoderInterface $encoder, |
||||||||||
50 | General $config, |
||||||||||
51 | FailureMessages $failureMessages |
||||||||||
52 | ) { |
||||||||||
53 | $this->actionFlag = $actionFlag; |
||||||||||
54 | $this->encoder = $encoder; |
||||||||||
55 | $this->config = $config; |
||||||||||
56 | |||||||||||
57 | parent::__construct($failureMessages); |
||||||||||
58 | } |
||||||||||
59 | |||||||||||
60 | /** |
||||||||||
61 | * Handle captcha failure |
||||||||||
62 | * |
||||||||||
63 | * @param Response $verifyReCaptcha |
||||||||||
64 | * @param ResponseInterface|null $response |
||||||||||
65 | * |
||||||||||
66 | * @return void |
||||||||||
67 | */ |
||||||||||
68 | public function execute(Response $verifyReCaptcha, ResponseInterface $response = null) |
||||||||||
69 | { |
||||||||||
70 | if ($response === null || !$response instanceof Http) { |
||||||||||
71 | return; |
||||||||||
72 | } |
||||||||||
73 | |||||||||||
74 | $this->actionFlag->set('', Action::FLAG_NO_DISPATCH, true); |
||||||||||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||||||||||
75 | |||||||||||
76 | $jsonPayload = $this->encoder->encode([ |
||||||||||
77 | 'errors' => true, |
||||||||||
78 | 'message' => $this->getMessagesString($verifyReCaptcha), |
||||||||||
79 | ]); |
||||||||||
80 | |||||||||||
81 | $response->representJson($jsonPayload); |
||||||||||
0 ignored issues
–
show
The method
representJson() does not exist on Magento\Framework\App\Request\Http .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. ![]() The method
representJson() does not exist on Magento\Framework\App\ResponseInterface . It seems like you code against a sub-type of Magento\Framework\App\ResponseInterface such as Magento\MediaStorage\Model\File\Storage\Response or Magento\Framework\App\Response\Http .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||||||
82 | } |
||||||||||
83 | } |
||||||||||
84 |