VerifyRecaptchaController.php
46 lines
| 1 | <?php |
| 2 | |
| 3 | namespace AmeliaBooking\Application\Controller\Google; |
| 4 | |
| 5 | use AmeliaBooking\Application\Commands\Google\VerifyRecaptchaCommand; |
| 6 | use AmeliaBooking\Application\Controller\Controller; |
| 7 | use Slim\Http\Request; |
| 8 | |
| 9 | /** |
| 10 | * Class VerifyRecaptchaController |
| 11 | * |
| 12 | * @package AmeliaBooking\Application\Controller\Google |
| 13 | */ |
| 14 | class VerifyRecaptchaController extends Controller |
| 15 | { |
| 16 | protected $allowedFields = [ |
| 17 | 'ameliaNonce', |
| 18 | 'wpAmeliaNonce', |
| 19 | 'secret', |
| 20 | 'token' |
| 21 | ]; |
| 22 | |
| 23 | /** |
| 24 | * @param Request $request |
| 25 | * @param $args |
| 26 | * |
| 27 | * @return VerifyRecaptchaCommand |
| 28 | */ |
| 29 | protected function instantiateCommand(Request $request, $args) |
| 30 | { |
| 31 | $command = new VerifyRecaptchaCommand($args); |
| 32 | $requestBody = $request->getParsedBody(); |
| 33 | |
| 34 | if (empty($requestBody)) { |
| 35 | $json = json_decode(file_get_contents('php://input'), true); |
| 36 | if (is_array($json)) { |
| 37 | $requestBody = $json; |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | $this->setCommandFields($command, $requestBody); |
| 42 | |
| 43 | return $command; |
| 44 | } |
| 45 | } |
| 46 |