fix: apply correct return type and response handling

This commit is contained in:
Björn Fromme
2026-03-16 12:01:09 +01:00
parent c18ba3d815
commit 96d4b8ed45
4 changed files with 9 additions and 8 deletions
+3 -3
View File
@@ -9,7 +9,7 @@ use App\BusProNet\Model\BaseData;
use App\BusProNet\Model\Booking;
use App\BusProNet\Model\BookingResponse;
use App\BusProNet\Model\BookingUpdate;
use App\BusProNet\Model\ContactFormResponse;
use App\BusProNet\Model\RegistrationResponse;
use App\BusProNet\Model\CrmAttributes;
use App\BusProNet\Model\Notification;
use App\BusProNet\Model\PersonalData;
@@ -79,7 +79,7 @@ class ApiClient
/**
* @throws ApiClientException
*/
public function register(RegistrationDto $registrationData): Notification
public function register(RegistrationDto $registrationData): Notification|RegistrationResponse
{
$data = [
'user' => $this->config['bpn_username'],
@@ -144,7 +144,7 @@ class ApiClient
public function createAddress(
PersonalData $personalData,
bool $debug = false,
): ContactFormResponse|Notification {
): RegistrationResponse|Notification {
$data = [
'user' => $this->config['bpn_username'],
'key' => $this->createKey($this->config['bpn_username'], $this->config['bpn_password'], static::TYPE_CUSTOMER_DATA),
@@ -4,7 +4,7 @@ declare(strict_types=1);
namespace App\BusProNet\Model;
class ContactFormResponse
class RegistrationResponse
{
public function __construct(
public readonly int $addressId,
@@ -4,18 +4,18 @@ declare(strict_types=1);
namespace App\BusProNet\XmlParser;
use App\BusProNet\Model\ContactFormResponse;
use App\BusProNet\Model\RegistrationResponse;
use Symfony\Component\DomCrawler\Crawler;
class ContactFormResponseParser extends AbstractParser
{
public function parse(Crawler $node): ContactFormResponse
public function parse(Crawler $node): RegistrationResponse
{
$addressId = (int) $node->filterXPath('//idadresse')->text();
$personId = (int) $node->filterXPath('//idperson')->text();
$isNewRecord = $this->getBoolValue($node->filterXPath('//neuanlage'));
return new ContactFormResponse(
return new RegistrationResponse(
addressId: $addressId,
personId: $personId,
isNewRecord: $isNewRecord,
+2 -1
View File
@@ -4,6 +4,7 @@ namespace App\Controller;
use App\BusProNet\ApiClient;
use App\BusProNet\Exception\ApiClientException;
use App\BusProNet\Model\Notification;
use App\Form\Model\RegistrationDto;
use App\Form\RegistrationType;
use Psr\Log\LoggerInterface;
@@ -34,7 +35,7 @@ class RegistrationController extends AbstractController
if ($form->isSubmitted() && $form->isValid()) {
try {
$response = $this->apiClient->register($registrationData);
if (true === $response->isError()) {
if ($response instanceof Notification && true === $response->isError()) {
$this->addFlash('error', 'Möglicherweise bist du bereits registriert. Bitte setze dein Passwort zurück.');
} else {
$this->addFlash('success', 'Du erhältst in Kürze eine E-Mail mit einem Link zum (Zurück)setzen deines Passworts.');