Code cleanup
This commit is contained in:
@@ -1,10 +1,32 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace EP\EpTheme\Form;
|
namespace EP\EpTheme\Form;
|
||||||
|
|
||||||
|
/***************************************************************
|
||||||
|
*
|
||||||
|
* Copyright notice
|
||||||
|
*
|
||||||
|
* (c) 2019 Björn Fromme <[email protected]>, 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 EP\EpTheme\Service\BookingApiService;
|
||||||
use Symfony\Component\OptionsResolver\Exception\MissingOptionsException;
|
|
||||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
|
||||||
use TYPO3\CMS\Form\Domain\Finishers\AbstractFinisher;
|
use TYPO3\CMS\Form\Domain\Finishers\AbstractFinisher;
|
||||||
|
|
||||||
class BpnApiFinisher extends AbstractFinisher
|
class BpnApiFinisher extends AbstractFinisher
|
||||||
@@ -22,32 +44,9 @@ class BpnApiFinisher extends AbstractFinisher
|
|||||||
$this->bookingApiService = $bookingApiService;
|
$this->bookingApiService = $bookingApiService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string|null
|
|
||||||
*/
|
|
||||||
protected function executeInternal()
|
protected function executeInternal()
|
||||||
{
|
{
|
||||||
$formValues = $this->finisherContext->getFormValues();
|
$formValues = $this->finisherContext->getFormValues();
|
||||||
$optionsResolver = new OptionsResolver();
|
$this->bookingApiService->registerAddress($formValues);
|
||||||
$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) {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,31 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace EP\EpTheme\Service;
|
namespace EP\EpTheme\Service;
|
||||||
|
|
||||||
|
/***************************************************************
|
||||||
|
*
|
||||||
|
* Copyright notice
|
||||||
|
*
|
||||||
|
* (c) 2019 Björn Fromme <[email protected]>, 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\LoggerAwareInterface;
|
||||||
use Psr\Log\LoggerAwareTrait;
|
use Psr\Log\LoggerAwareTrait;
|
||||||
use Symfony\Component\HttpClient\HttpClient;
|
use Symfony\Component\HttpClient\HttpClient;
|
||||||
@@ -45,7 +69,6 @@ class BookingApiService implements SingletonInterface, LoggerAwareInterface
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $addressData
|
* @param array $addressData
|
||||||
* @throws TransportExceptionInterface
|
|
||||||
*/
|
*/
|
||||||
public function registerAddress(array $addressData)
|
public function registerAddress(array $addressData)
|
||||||
{
|
{
|
||||||
@@ -61,8 +84,7 @@ class BookingApiService implements SingletonInterface, LoggerAwareInterface
|
|||||||
'body' => json_encode($addressData),
|
'body' => json_encode($addressData),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
catch (\Exception $e)
|
catch (TransportExceptionInterface $e) {
|
||||||
{
|
|
||||||
$this->logger->error($e->getMessage());
|
$this->logger->error($e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,11 +10,11 @@ finishers:
|
|||||||
identifier: BpnApiFinisher
|
identifier: BpnApiFinisher
|
||||||
-
|
-
|
||||||
options:
|
options:
|
||||||
subject: 'Kontaktanfrage von {firstName} {name}'
|
subject: 'Kontaktanfrage von {firstName} {lastName}'
|
||||||
recipientAddress: [email protected]
|
recipientAddress: [email protected]
|
||||||
recipientName: 'E&P Reisen'
|
recipientName: 'E&P Reisen'
|
||||||
senderAddress: '{email}'
|
senderAddress: '{email}'
|
||||||
senderName: '{firstName} {name}'
|
senderName: '{firstName} {lastName}'
|
||||||
replyToAddress: [email protected]
|
replyToAddress: [email protected]
|
||||||
carbonCopyAddress: ''
|
carbonCopyAddress: ''
|
||||||
blindCarbonCopyAddress: ''
|
blindCarbonCopyAddress: ''
|
||||||
@@ -53,8 +53,8 @@ renderables:
|
|||||||
-
|
-
|
||||||
defaultValue: ''
|
defaultValue: ''
|
||||||
type: Text
|
type: Text
|
||||||
identifier: name
|
identifier: lastName
|
||||||
label: Nachname
|
label: 'Nachname'
|
||||||
properties:
|
properties:
|
||||||
fluidAdditionalAttributes:
|
fluidAdditionalAttributes:
|
||||||
placeholder: 'Nachname'
|
placeholder: 'Nachname'
|
||||||
@@ -73,7 +73,7 @@ renderables:
|
|||||||
required: required
|
required: required
|
||||||
type: SingleSelect
|
type: SingleSelect
|
||||||
identifier: gender
|
identifier: gender
|
||||||
label: Gender
|
label: 'Gender'
|
||||||
validators:
|
validators:
|
||||||
-
|
-
|
||||||
identifier: NotEmpty
|
identifier: NotEmpty
|
||||||
@@ -81,7 +81,7 @@ renderables:
|
|||||||
defaultValue: ''
|
defaultValue: ''
|
||||||
type: Text
|
type: Text
|
||||||
identifier: email
|
identifier: email
|
||||||
label: E-Mail
|
label: 'E-Mail'
|
||||||
properties:
|
properties:
|
||||||
fluidAdditionalAttributes:
|
fluidAdditionalAttributes:
|
||||||
required: required
|
required: required
|
||||||
@@ -94,7 +94,7 @@ renderables:
|
|||||||
defaultValue: ''
|
defaultValue: ''
|
||||||
type: Text
|
type: Text
|
||||||
identifier: street
|
identifier: street
|
||||||
label: Straße
|
label: 'Straße'
|
||||||
properties:
|
properties:
|
||||||
fluidAdditionalAttributes:
|
fluidAdditionalAttributes:
|
||||||
placeholder: 'Straße & Nr.'
|
placeholder: 'Straße & Nr.'
|
||||||
@@ -113,7 +113,7 @@ renderables:
|
|||||||
defaultValue: ''
|
defaultValue: ''
|
||||||
type: Text
|
type: Text
|
||||||
identifier: phone
|
identifier: phone
|
||||||
label: Telefon
|
label: 'Telefon'
|
||||||
-
|
-
|
||||||
defaultValue: ''
|
defaultValue: ''
|
||||||
type: Textarea
|
type: Textarea
|
||||||
|
|||||||
Reference in New Issue
Block a user