From 1ec50a526f0728de244832c3e895a2572d1b39fd Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Tue, 5 Dec 2023 08:55:20 +0100 Subject: [PATCH] Manually fix issues arisen from auto fixing stuff --- Classes/Domain/Import/Entity/Base.php | 2 +- Classes/Domain/Import/Entity/Place.php | 6 +++--- Classes/Domain/Import/Entity/Shared/ManagedBy.php | 2 +- Classes/Domain/Import/EntityMapper/JsonDecode.php | 2 +- .../Import/Typo3Converter/NameExtractor.php | 2 +- .../Model/Backend/ImportLogEntry/MappingError.php | 9 +++++++-- .../Model/Backend/ImportLogEntry/SavingEntity.php | 8 +++++++- .../Model/Frontend/AccessiblitySpecification.php | 2 +- Classes/Domain/Model/Frontend/Address.php | 2 +- Classes/Domain/Model/Frontend/Media.php | 2 +- Classes/Domain/Model/Frontend/Offers.php | 2 +- Classes/Domain/Model/Frontend/OpeningHours.php | 2 +- Classes/Domain/Model/Frontend/Place.php | 15 +++++++++++++++ .../Domain/Model/Frontend/TouristAttraction.php | 10 ++++++++++ Configuration/Extbase/Persistence/Classes.php | 13 +++++++++++-- Documentation/Maintenance.rst | 2 +- Documentation/Maintenance/Extbase.rst | 15 +++++++++++++++ .../ContentElement/TouristAttraction.html | 9 +++++---- .../Unit/Domain/Import/Importer/FetchDataTest.php | 2 +- .../Typo3Converter/GeneralConverterTest.php | 1 + 20 files changed, 85 insertions(+), 23 deletions(-) create mode 100644 Documentation/Maintenance/Extbase.rst diff --git a/Classes/Domain/Import/Entity/Base.php b/Classes/Domain/Import/Entity/Base.php index c3a92ec..3efcba1 100644 --- a/Classes/Domain/Import/Entity/Base.php +++ b/Classes/Domain/Import/Entity/Base.php @@ -30,7 +30,7 @@ class Base extends Minimum { use ManagedBy; - protected ForeignReference $photo; + protected ?ForeignReference $photo = null; /** * Images of this Thing. diff --git a/Classes/Domain/Import/Entity/Place.php b/Classes/Domain/Import/Entity/Place.php index 7500e82..4f67767 100644 --- a/Classes/Domain/Import/Entity/Place.php +++ b/Classes/Domain/Import/Entity/Place.php @@ -39,9 +39,9 @@ class Place extends Base use Organization; use ContainedInPlace; - protected Address $address; + protected ?Address $address = null; - protected Geo $geo; + protected ?Geo $geo = null; /** * @var OpeningHour[] @@ -80,7 +80,7 @@ class Place extends Base protected string $distanceToPublicTransport = ''; - protected ForeignReference $accessibilitySpecification; + protected ?ForeignReference $accessibilitySpecification = null; public function getAddress(): ?Address { diff --git a/Classes/Domain/Import/Entity/Shared/ManagedBy.php b/Classes/Domain/Import/Entity/Shared/ManagedBy.php index 4704cca..50115f2 100644 --- a/Classes/Domain/Import/Entity/Shared/ManagedBy.php +++ b/Classes/Domain/Import/Entity/Shared/ManagedBy.php @@ -30,7 +30,7 @@ trait ManagedBy /** * The Thing responsible for the data within this Thing. */ - protected ?ForeignReference $managedBy; + protected ?ForeignReference $managedBy = null; public function getManagedBy(): ?ForeignReference { diff --git a/Classes/Domain/Import/EntityMapper/JsonDecode.php b/Classes/Domain/Import/EntityMapper/JsonDecode.php index 809a91f..4e0c518 100644 --- a/Classes/Domain/Import/EntityMapper/JsonDecode.php +++ b/Classes/Domain/Import/EntityMapper/JsonDecode.php @@ -235,7 +235,7 @@ class JsonDecode extends SymfonyJsonDecode private function doesRuleMatch(array $rule, string $type): bool { if ($rule['type'] === 'beginsWith') { - return str_starts_with($type, (string) $rule['comparisonValue']); + return str_starts_with($type, (string)$rule['comparisonValue']); } return false; diff --git a/Classes/Domain/Import/Typo3Converter/NameExtractor.php b/Classes/Domain/Import/Typo3Converter/NameExtractor.php index 13e0c78..85fdc24 100644 --- a/Classes/Domain/Import/Typo3Converter/NameExtractor.php +++ b/Classes/Domain/Import/Typo3Converter/NameExtractor.php @@ -59,7 +59,7 @@ class NameExtractor } if ($name === '' && method_exists($remote, 'getName')) { - $name = trim((string) $remote->getName()); + $name = trim((string)$remote->getName()); } return $name; diff --git a/Classes/Domain/Model/Backend/ImportLogEntry/MappingError.php b/Classes/Domain/Model/Backend/ImportLogEntry/MappingError.php index e2515c4..ef13af6 100644 --- a/Classes/Domain/Model/Backend/ImportLogEntry/MappingError.php +++ b/Classes/Domain/Model/Backend/ImportLogEntry/MappingError.php @@ -31,7 +31,12 @@ class MappingError extends ImportLogEntry { protected string $remoteId = ''; - protected string $errors = ''; + /** + * Necessary for Extbase/Symfony. + * + * @var string + */ + protected string $errors = '[]'; public function __construct( MappingException $exception @@ -47,7 +52,7 @@ class MappingError extends ImportLogEntry public function getErrors(): array { - $errors = json_decode($this->errors, true, 512, JSON_THROW_ON_ERROR); + $errors = json_decode($this->errors, true); if (is_array($errors) === false) { throw new Exception('Could not parse errors.', 1671097690); } diff --git a/Classes/Domain/Model/Backend/ImportLogEntry/SavingEntity.php b/Classes/Domain/Model/Backend/ImportLogEntry/SavingEntity.php index ac5efb2..2ef6ecb 100644 --- a/Classes/Domain/Model/Backend/ImportLogEntry/SavingEntity.php +++ b/Classes/Domain/Model/Backend/ImportLogEntry/SavingEntity.php @@ -41,18 +41,24 @@ class SavingEntity extends ImportLogEntry protected string $errors = ''; + /** + * @var string[] + */ + protected array $errorsAsArray = []; + /** * @param string[] $errorsAsArray */ public function __construct( Entity $entity, - protected array $errorsAsArray + array $errorsAsArray ) { $this->remoteId = $entity->getRemoteId(); $this->insertion = $entity->wasCreated(); $this->recordUid = $entity->getTypo3Uid(); $this->recordPid = $entity->getTypo3StoragePid(); $this->tableName = $entity->getTypo3DatabaseTableName(); + $this->errorsAsArray = $errorsAsArray; } public function getRemoteId(): string diff --git a/Classes/Domain/Model/Frontend/AccessiblitySpecification.php b/Classes/Domain/Model/Frontend/AccessiblitySpecification.php index 21e6f70..e83728e 100644 --- a/Classes/Domain/Model/Frontend/AccessiblitySpecification.php +++ b/Classes/Domain/Model/Frontend/AccessiblitySpecification.php @@ -35,7 +35,7 @@ class AccessiblitySpecification implements TypeInterface public function __construct( private readonly string $serialized ) { - $this->data = json_decode($serialized, true, 512, JSON_THROW_ON_ERROR); + $this->data = json_decode($serialized, true); } public function getCertificationStatus(): string diff --git a/Classes/Domain/Model/Frontend/Address.php b/Classes/Domain/Model/Frontend/Address.php index 1aaf63b..5e08c15 100644 --- a/Classes/Domain/Model/Frontend/Address.php +++ b/Classes/Domain/Model/Frontend/Address.php @@ -35,7 +35,7 @@ class Address implements TypeInterface public function __construct( private readonly string $serialized ) { - $this->data = json_decode($serialized, true, 512, JSON_THROW_ON_ERROR); + $this->data = json_decode($serialized, true) ?? []; } public function getStreet(): string diff --git a/Classes/Domain/Model/Frontend/Media.php b/Classes/Domain/Model/Frontend/Media.php index 1330131..8c82522 100644 --- a/Classes/Domain/Model/Frontend/Media.php +++ b/Classes/Domain/Model/Frontend/Media.php @@ -41,7 +41,7 @@ class Media implements TypeInterface public function __construct( private readonly string $serialized ) { - $data = json_decode($serialized, true, 512, JSON_THROW_ON_ERROR); + $data = json_decode($serialized, true); $this->data = $this->prepareData(is_array($data) ? $data : []); } diff --git a/Classes/Domain/Model/Frontend/Offers.php b/Classes/Domain/Model/Frontend/Offers.php index 87ab4d2..17a3765 100644 --- a/Classes/Domain/Model/Frontend/Offers.php +++ b/Classes/Domain/Model/Frontend/Offers.php @@ -42,7 +42,7 @@ class Offers implements TypeInterface, Iterator, Countable public function __construct( private readonly string $serialized ) { - $array = json_decode($serialized, true, 512, JSON_THROW_ON_ERROR); + $array = json_decode($serialized, true); if (is_array($array)) { $array = array_map([Offer::class, 'createFromArray'], $array); usort($array, function (Offer $offerA, Offer $offerB) { diff --git a/Classes/Domain/Model/Frontend/OpeningHours.php b/Classes/Domain/Model/Frontend/OpeningHours.php index 9cd2ba0..6b07adb 100644 --- a/Classes/Domain/Model/Frontend/OpeningHours.php +++ b/Classes/Domain/Model/Frontend/OpeningHours.php @@ -52,7 +52,7 @@ class OpeningHours implements TypeInterface, Iterator, Countable { $array = array_map( [OpeningHour::class, 'createFromArray'], - json_decode($serialized, true, 512, JSON_THROW_ON_ERROR) ?? [] + json_decode($serialized, true) ?? [] ); $array = GeneralUtility::makeInstance(DateBasedFilter::class) diff --git a/Classes/Domain/Model/Frontend/Place.php b/Classes/Domain/Model/Frontend/Place.php index e40fcd2..3b79474 100644 --- a/Classes/Domain/Model/Frontend/Place.php +++ b/Classes/Domain/Model/Frontend/Place.php @@ -41,14 +41,29 @@ abstract class Place extends Base */ protected ObjectStorage $parkingFacilityNearBy; + /** + * Necessary for Extbase/Symfony. + * + * @var string + */ protected string $sanitation = ''; protected string $otherService = ''; protected string $trafficInfrastructure = ''; + /** + * Necessary for Extbase/Symfony. + * + * @var string + */ protected string $paymentAccepted = ''; + /** + * Necessary for Extbase/Symfony. + * + * @var string + */ protected string $distanceToPublicTransport = ''; protected ?AccessiblitySpecification $accessibilitySpecification = null; diff --git a/Classes/Domain/Model/Frontend/TouristAttraction.php b/Classes/Domain/Model/Frontend/TouristAttraction.php index b7ea300..7a85f42 100644 --- a/Classes/Domain/Model/Frontend/TouristAttraction.php +++ b/Classes/Domain/Model/Frontend/TouristAttraction.php @@ -39,8 +39,18 @@ class TouristAttraction extends Place protected string $architecturalStyle = ''; + /** + * Necessary for Extbase/Symfony. + * + * @var string + */ protected string $digitalOffer = ''; + /** + * Necessary for Extbase/Symfony. + * + * @var string + */ protected string $photography = ''; protected string $petsAllowed = ''; diff --git a/Configuration/Extbase/Persistence/Classes.php b/Configuration/Extbase/Persistence/Classes.php index 54d44d1..827a781 100644 --- a/Configuration/Extbase/Persistence/Classes.php +++ b/Configuration/Extbase/Persistence/Classes.php @@ -11,7 +11,9 @@ use WerkraumMedia\ThueCat\Domain\Model\Backend\Organisation; use WerkraumMedia\ThueCat\Domain\Model\Backend\ParkingFacility; use WerkraumMedia\ThueCat\Domain\Model\Backend\TouristInformation; use WerkraumMedia\ThueCat\Domain\Model\Backend\Town; -use WerkraumMedia\ThueCat\Domain\Model\Frontend\TouristAttraction; +use WerkraumMedia\ThueCat\Domain\Model\Frontend\ParkingFacility as FrontendParkingFacility; +use WerkraumMedia\ThueCat\Domain\Model\Frontend\TouristAttraction as FrontendTouristAttraction; +use WerkraumMedia\ThueCat\Domain\Model\Frontend\Town as FrontendTown; return [ Organisation::class => [ @@ -47,7 +49,14 @@ return [ 'tableName' => 'tx_thuecat_import_log_entry', 'recordType' => 'mappingError', ], - TouristAttraction::class => [ + + FrontendTouristAttraction::class => [ 'tableName' => 'tx_thuecat_tourist_attraction', ], + FrontendTown::class => [ + 'tableName' => 'tx_thuecat_town', + ], + FrontendParkingFacility::class => [ + 'tableName' => 'tx_thuecat_parking_facility', + ], ]; diff --git a/Documentation/Maintenance.rst b/Documentation/Maintenance.rst index bc79526..14ca383 100644 --- a/Documentation/Maintenance.rst +++ b/Documentation/Maintenance.rst @@ -14,4 +14,4 @@ Those changes are documented so we know what to do once we drop an older version :glob: :reversed: - Maintenance/PHP/* + Maintenance/* diff --git a/Documentation/Maintenance/Extbase.rst b/Documentation/Maintenance/Extbase.rst new file mode 100644 index 0000000..338adc0 --- /dev/null +++ b/Documentation/Maintenance/Extbase.rst @@ -0,0 +1,15 @@ +.. _maintenanceExtbase: + +Extbase +======= + +PHPDoc Blocks with type hints mentioning `Necessary for Extbase/Symfony.` +------------------------------------------------------------------------- + +Those are necessary (at least with TYPO3 v12) because of Extbase and the underlying +Symfony component. + +Extbase uses the PHPDocExtractor first, before using the `ReflectionExtractor`, both part of Symfony property-info package. +The `ReflectionExtractor` will check the mutator followed by accessors prior checking the property itself. +Some of our properties have different return values by accessors than the stored value that is set to the property. +We therefore need to keep the PHPDoc block as this is checked first. diff --git a/Resources/Private/Templates/Frontend/ContentElement/TouristAttraction.html b/Resources/Private/Templates/Frontend/ContentElement/TouristAttraction.html index cee0610..b75f2fe 100644 --- a/Resources/Private/Templates/Frontend/ContentElement/TouristAttraction.html +++ b/Resources/Private/Templates/Frontend/ContentElement/TouristAttraction.html @@ -71,10 +71,10 @@
-

{f:translate(id: 'content.generalInformation', extensionName: 'Thuecat')}

@@ -109,6 +109,7 @@

{f:translate(id: 'content.sanitation', extensionName: 'Thuecat')}

+ sanitation {f:render(partial: 'Sanitation', arguments: {sanitation: entity.sanitation})}
diff --git a/Tests/Unit/Domain/Import/Importer/FetchDataTest.php b/Tests/Unit/Domain/Import/Importer/FetchDataTest.php index 96b44f6..d604e75 100644 --- a/Tests/Unit/Domain/Import/Importer/FetchDataTest.php +++ b/Tests/Unit/Domain/Import/Importer/FetchDataTest.php @@ -103,7 +103,7 @@ class FetchDataTest extends TestCase $httpClient->method('sendRequest')->willReturn($response); $body = $this->createStub(StreamInterface::class); - $body->method('__toString')->willReturn(''); + $body->method('__toString')->willReturn('[]'); $response->method('getStatusCode')->willReturn(200); $response->method('getBody')->willReturn($body); diff --git a/Tests/Unit/Domain/Import/Typo3Converter/GeneralConverterTest.php b/Tests/Unit/Domain/Import/Typo3Converter/GeneralConverterTest.php index 99aea4c..34eba57 100644 --- a/Tests/Unit/Domain/Import/Typo3Converter/GeneralConverterTest.php +++ b/Tests/Unit/Domain/Import/Typo3Converter/GeneralConverterTest.php @@ -53,6 +53,7 @@ class GeneralConverterTest extends TestCase $parkingFacilityRepository = $this->createStub(ParkingFacilityRepository::class); $nameExtractor = $this->createStub(NameExtractor::class); $logManager = $this->createStub(LogManager::class); + $logManager->method('getLogger')->willReturn($this->createStub(Logger::class)); $subject = new GeneralConverter( $resolveForeignReference,