From 5c5b7229728cb0c2992bc6933eec2f062c1f95eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Fromme?= Date: Tue, 1 Oct 2019 20:54:35 +0200 Subject: [PATCH] Code cleanup --- .../ep_theme/Classes/Form/BpnApiFinisher.php | 53 +++++++++---------- .../Classes/Service/BookingApiService.php | 30 +++++++++-- .../Private/Forms/ContactForm.form.yaml | 16 +++--- 3 files changed, 60 insertions(+), 39 deletions(-) diff --git a/public/typo3conf/ext/ep_theme/Classes/Form/BpnApiFinisher.php b/public/typo3conf/ext/ep_theme/Classes/Form/BpnApiFinisher.php index 93195475..6f1f3fa2 100644 --- a/public/typo3conf/ext/ep_theme/Classes/Form/BpnApiFinisher.php +++ b/public/typo3conf/ext/ep_theme/Classes/Form/BpnApiFinisher.php @@ -1,10 +1,32 @@ , dreipunktnull + * + * All rights reserved + * + * This script is part of the TYPO3 project. The TYPO3 project is + * free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * The GNU General Public License can be found at + * http://www.gnu.org/copyleft/gpl.html. + * + * This script is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * This copyright notice MUST APPEAR in all copies of the script! + ***************************************************************/ + use EP\EpTheme\Service\BookingApiService; -use Symfony\Component\OptionsResolver\Exception\MissingOptionsException; -use Symfony\Component\OptionsResolver\OptionsResolver; use TYPO3\CMS\Form\Domain\Finishers\AbstractFinisher; class BpnApiFinisher extends AbstractFinisher @@ -22,32 +44,9 @@ class BpnApiFinisher extends AbstractFinisher $this->bookingApiService = $bookingApiService; } - /** - * @return string|null - */ protected function executeInternal() { $formValues = $this->finisherContext->getFormValues(); - $optionsResolver = new OptionsResolver(); - $optionsResolver->setRequired(['lastName', 'firstName', 'gender', 'email']); - $optionsResolver->setDefined([ - 'lastName', 'firstName', 'gender', 'email', 'street', 'zipCode', 'city', 'phone' - ]); - $addressData = [ - 'lastName' => $formValues['name'], - 'firstName' => $formValues['firstName'], - 'gender' => $formValues['gender'], - 'email' => $formValues['email'], - 'street' => $formValues['street'], - 'zipCode' => $formValues['zipCode'], - 'city' => $formValues['city'], - 'phone' => $formValues['phone'], - ]; - try { - $sanitizedFormData = $optionsResolver->resolve($addressData); - $this->bookingApiService->registerAddress($sanitizedFormData); - } - catch (MissingOptionsException $e) { - } + $this->bookingApiService->registerAddress($formValues); } } \ No newline at end of file diff --git a/public/typo3conf/ext/ep_theme/Classes/Service/BookingApiService.php b/public/typo3conf/ext/ep_theme/Classes/Service/BookingApiService.php index a2133cf6..977681ee 100644 --- a/public/typo3conf/ext/ep_theme/Classes/Service/BookingApiService.php +++ b/public/typo3conf/ext/ep_theme/Classes/Service/BookingApiService.php @@ -1,7 +1,31 @@ , dreipunktnull + * + * All rights reserved + * + * This script is part of the TYPO3 project. The TYPO3 project is + * free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * The GNU General Public License can be found at + * http://www.gnu.org/copyleft/gpl.html. + * + * This script is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * This copyright notice MUST APPEAR in all copies of the script! + ***************************************************************/ + use Psr\Log\LoggerAwareInterface; use Psr\Log\LoggerAwareTrait; use Symfony\Component\HttpClient\HttpClient; @@ -45,7 +69,6 @@ class BookingApiService implements SingletonInterface, LoggerAwareInterface /** * @param array $addressData - * @throws TransportExceptionInterface */ public function registerAddress(array $addressData) { @@ -61,8 +84,7 @@ class BookingApiService implements SingletonInterface, LoggerAwareInterface 'body' => json_encode($addressData), ]); } - catch (\Exception $e) - { + catch (TransportExceptionInterface $e) { $this->logger->error($e->getMessage()); } } diff --git a/public/typo3conf/ext/ep_theme/Resources/Private/Forms/ContactForm.form.yaml b/public/typo3conf/ext/ep_theme/Resources/Private/Forms/ContactForm.form.yaml index ae6fd830..8e75ef49 100644 --- a/public/typo3conf/ext/ep_theme/Resources/Private/Forms/ContactForm.form.yaml +++ b/public/typo3conf/ext/ep_theme/Resources/Private/Forms/ContactForm.form.yaml @@ -10,11 +10,11 @@ finishers: identifier: BpnApiFinisher - options: - subject: 'Kontaktanfrage von {firstName} {name}' + subject: 'Kontaktanfrage von {firstName} {lastName}' recipientAddress: info@ep-reisen.de recipientName: 'E&P Reisen' senderAddress: '{email}' - senderName: '{firstName} {name}' + senderName: '{firstName} {lastName}' replyToAddress: info@ep-reisen.de carbonCopyAddress: '' blindCarbonCopyAddress: '' @@ -53,8 +53,8 @@ renderables: - defaultValue: '' type: Text - identifier: name - label: Nachname + identifier: lastName + label: 'Nachname' properties: fluidAdditionalAttributes: placeholder: 'Nachname' @@ -73,7 +73,7 @@ renderables: required: required type: SingleSelect identifier: gender - label: Gender + label: 'Gender' validators: - identifier: NotEmpty @@ -81,7 +81,7 @@ renderables: defaultValue: '' type: Text identifier: email - label: E-Mail + label: 'E-Mail' properties: fluidAdditionalAttributes: required: required @@ -94,7 +94,7 @@ renderables: defaultValue: '' type: Text identifier: street - label: Straße + label: 'Straße' properties: fluidAdditionalAttributes: placeholder: 'Straße & Nr.' @@ -113,7 +113,7 @@ renderables: defaultValue: '' type: Text identifier: phone - label: Telefon + label: 'Telefon' - defaultValue: '' type: Textarea