Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for slogan as array #118

Merged
merged 1 commit into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions Classes/Domain/Import/Entity/TouristAttraction.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
class TouristAttraction extends Place implements MapsToType
{
/**
* @var string
* @var string[]
*/
protected $slogan = '';
protected $slogan = [];

/**
* @var string
Expand Down Expand Up @@ -77,7 +77,7 @@ class TouristAttraction extends Place implements MapsToType
*/
protected $availableLanguages = [];

public function getSlogan(): string
public function getSlogan(): array
{
return $this->slogan;
}
Expand Down Expand Up @@ -144,10 +144,15 @@ public function getAvailableLanguages(): array

/**
* @internal for mapping via Symfony component.
*
* @param string|array $slogan
*/
public function setSlogan(string $slogan): void
public function setSlogan($slogan): void
{
$this->slogan = PropertyValues::removePrefixFromEntry($slogan);
if (is_string($slogan)) {
$slogan = [$slogan];
}
$this->slogan = PropertyValues::removePrefixFromEntries($slogan);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion Classes/Domain/Import/Typo3Converter/GeneralConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ private function buildDataArrayFromEntity(
'payment_accepted' => method_exists($entity, 'getPaymentsAccepted') ? implode(',', $entity->getPaymentsAccepted()) : '',
'distance_to_public_transport' => method_exists($entity, 'getDistanceToPublicTransport') ? $entity->getDistanceToPublicTransport() : '',

'slogan' => method_exists($entity, 'getSlogan') ? $entity->getSlogan() : '',
'slogan' => method_exists($entity, 'getSlogan') ? implode(',', $entity->getSlogan()) : '',
'start_of_construction' => method_exists($entity, 'getStartOfConstruction') ? $entity->getStartOfConstruction() : '',
'museum_service' => method_exists($entity, 'getMuseumServices') ? implode(',', $entity->getMuseumServices()) : '',
'architectural_style' => method_exists($entity, 'getArchitecturalStyles') ? implode(',', $entity->getArchitecturalStyles()) : '',
Expand Down
10 changes: 9 additions & 1 deletion Classes/Domain/Model/Frontend/TouristAttraction.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,15 @@ class TouristAttraction extends Place

public function getSlogan(): string
{
return $this->slogan;
return explode(',', $this->slogan)[0] ?? '';
}

/**
* @return string[]
*/
public function getSlogans(): array
{
return explode(',', $this->slogan);
}

public function getOffers(): ?Offers
Expand Down
31 changes: 31 additions & 0 deletions Documentation/Changelog/2.2.0.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
2.2.0
=====

Breaking
--------

Nothing

Features
--------

* Add support for multiple slogans (array within slogan).
The existing API will return the first slogan.
A new method `getSlogans` is added which will return the array of slogans.

Fixes
-----

Nothing

Tasks
-----

* Add PHP data for testing framework to ease backports.
As we have migrated on current main already.

Deprecation
-----------

Nothing

3 changes: 3 additions & 0 deletions Tests/Functional/AbstractImportTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,14 @@

namespace WerkraumMedia\ThueCat\Tests\Functional;

use Codappix\Typo3PhpDatasets\TestingFramework;
use TYPO3\CMS\Core\Localization\LanguageService;
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;

abstract class AbstractImportTest extends FunctionalTestCase
{
use TestingFramework;

/**
* Whether to expect errors to be logged.
* Will check for no errors if set to false.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

declare(strict_types=1);

return [
'tx_thuecat_tourist_attraction' => [
0 => [
'uid' => '1',
'pid' => '10',
'sys_language_uid' => '0',
'l18n_parent' => '0',
'l10n_source' => '0',
'remote_id' => 'https://thuecat.org/resources/attraction-with-single-slogan',
'title' => 'Attraktion mit single slogan',
'slogan' => 'InsiderTip',
],
1 => [
'uid' => '2',
'pid' => '10',
'sys_language_uid' => '1',
'l18n_parent' => '1',
'l10n_source' => '1',
'remote_id' => 'https://thuecat.org/resources/attraction-with-single-slogan',
'title' => 'Attraction with single slogan',
'slogan' => 'InsiderTip',
],
],
];
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

declare(strict_types=1);

return [
'tx_thuecat_tourist_attraction' => [
0 => [
'uid' => '1',
'pid' => '10',
'sys_language_uid' => '0',
'l18n_parent' => '0',
'l10n_source' => '0',
'remote_id' => 'https://thuecat.org/resources/attraction-with-slogan-array',
'title' => 'Attraktion mit slogan array',
'slogan' => 'Highlight,InsiderTip,Unique',
],
1 => [
'uid' => '2',
'pid' => '10',
'sys_language_uid' => '1',
'l18n_parent' => '1',
'l10n_source' => '1',
'remote_id' => 'https://thuecat.org/resources/attraction-with-slogan-array',
'title' => 'Attraction with slogan array',
'slogan' => 'Highlight,InsiderTip,Unique',
],
],
];
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"@context": {
"cdb": "https://thuecat.org/ontology/cdb/1.0/",
"dachkg": "https://thuecat.org/ontology/dachkg/1.0/",
"dbo": "http://dbpedia.org/ontology/",
"dsv": "http://ontologies.sti-innsbruck.at/dsv/",
"foaf": "http://xmlns.com/foaf/0.1/",
"owl": "http://www.w3.org/2002/07/owl#",
"rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
"rdfs": "http://www.w3.org/2000/01/rdf-schema#",
"schema": "http://schema.org/",
"sh": "http://www.w3.org/ns/shacl#",
"thuecat": "https://thuecat.org/ontology/thuecat/1.0/",
"ttgds": "https://thuecat.org/ontology/ttgds/1.0/",
"xsd": "http://www.w3.org/2001/XMLSchema#"
},
"@graph": [
{
"@id": "https://thuecat.org/resources/attraction-with-single-slogan",
"@type": [
"schema:Place",
"schema:Thing",
"schema:TouristAttraction",
"ttgds:PointOfInterest"
],
"schema:availableLanguage": [
{
"@type": "thuecat:Language",
"@value": "thuecat:German"
},
{
"@type": "thuecat:Language",
"@value": "thuecat:English"
}
],
"schema:name": [
{
"@language": "de",
"@value": "Attraktion mit single slogan"
},
{
"@language": "en",
"@value": "Attraction with single slogan"
}
],
"schema:slogan": {
"@type": "thuecat:ThuSlogan",
"@value": "thuecat:InsiderTip"
},
"thuecat:contentResponsible": {
"@id": "https://thuecat.org/resources/018132452787-ngbe"
}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{
"@context": {
"cdb": "https://thuecat.org/ontology/cdb/1.0/",
"dachkg": "https://thuecat.org/ontology/dachkg/1.0/",
"dbo": "http://dbpedia.org/ontology/",
"dsv": "http://ontologies.sti-innsbruck.at/dsv/",
"foaf": "http://xmlns.com/foaf/0.1/",
"owl": "http://www.w3.org/2002/07/owl#",
"rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
"rdfs": "http://www.w3.org/2000/01/rdf-schema#",
"schema": "http://schema.org/",
"sh": "http://www.w3.org/ns/shacl#",
"thuecat": "https://thuecat.org/ontology/thuecat/1.0/",
"ttgds": "https://thuecat.org/ontology/ttgds/1.0/",
"xsd": "http://www.w3.org/2001/XMLSchema#"
},
"@graph": [
{
"@id": "https://thuecat.org/resources/attraction-with-slogan-array",
"@type": [
"schema:Place",
"schema:Thing",
"schema:TouristAttraction",
"ttgds:PointOfInterest"
],
"schema:availableLanguage": [
{
"@type": "thuecat:Language",
"@value": "thuecat:German"
},
{
"@type": "thuecat:Language",
"@value": "thuecat:English"
}
],
"schema:name": [
{
"@language": "de",
"@value": "Attraktion mit slogan array"
},
{
"@language": "en",
"@value": "Attraction with slogan array"
}
],
"schema:slogan": [
{
"@type": "thuecat:ThuSlogan",
"@value": "thuecat:Highlight"
},
{
"@type": "thuecat:ThuSlogan",
"@value": "thuecat:InsiderTip"
},
{
"@type": "thuecat:ThuSlogan",
"@value": "thuecat:Unique"
}
],
"thuecat:contentResponsible": {
"@id": "https://thuecat.org/resources/018132452787-ngbe"
}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?php

declare(strict_types=1);

use TYPO3\CMS\Core\Domain\Repository\PageRepository;

return [
'pages' => [
0 => [
'uid' => '1',
'pid' => '0',
'tstamp' => '1613400587',
'crdate' => '1613400558',
'doktype' => PageRepository::DOKTYPE_DEFAULT,
'title' => 'Rootpage',
'is_siteroot' => '1',
],
1 => [
'uid' => '10',
'pid' => '1',
'tstamp' => '1613400587',
'crdate' => '1613400558',
'doktype' => PageRepository::DOKTYPE_SYSFOLDER,
'title' => 'Storage folder',
],
],
'sys_language' => [
0 => [
'uid' => 1,
'pid' => 0,
'title' => 'English',
'flag' => 'en-us-gb',
'language_isocode' => 'en',
],
1 => [
'uid' => 2,
'pid' => 0,
'title' => 'French',
'flag' => 'fr',
'language_isocode' => 'fr',
],
],
'tx_thuecat_import_configuration' => [
0 => [
'uid' => '1',
'pid' => '0',
'tstamp' => '1613400587',
'crdate' => '1613400558',
'disable' => '0',
'title' => 'Tourist Attraction',
'type' => 'static',
'configuration' => '<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<T3FlexForms>
<data>
<sheet index="sDEF">
<language index="lDEF">
<field index="storagePid">
<value index="vDEF">10</value>
</field>
<field index="urls">
<el index="el">
<field index="602a89f54d694654233086">
<value index="url">
<el>
<field index="url">
<value index="vDEF">https://thuecat.org/resources/attraction-with-single-slogan</value>
</field>
</el>
</value>
<value index="_TOGGLE">0</value>
</field>
</el>
</field>
</language>
</sheet>
</data>
</T3FlexForms>
',
],
],
];
Loading