From 1333ad40f97d82e55e2fc8772d65f4cfa6e07938 Mon Sep 17 00:00:00 2001 From: Wouter Vanelslander Date: Thu, 13 Jan 2022 14:29:03 +0100 Subject: [PATCH 01/13] PUBLIQ-499: Added searchOrganizer method + mock data + organizer parsing --- data/organizers.json | 470 ++++++++++++++++++++++++++++++++ src/SearchClient.php | 11 +- src/SearchClientInterface.php | 2 + src/ValueObjects/Collection.php | 2 + src/ValueObjects/Image.php | 108 ++++++++ src/ValueObjects/Organizer.php | 244 ++++++++++++++++- 6 files changed, 828 insertions(+), 9 deletions(-) create mode 100644 data/organizers.json create mode 100644 src/ValueObjects/Image.php diff --git a/data/organizers.json b/data/organizers.json new file mode 100644 index 00000000..e8e2a485 --- /dev/null +++ b/data/organizers.json @@ -0,0 +1,470 @@ +{ + "@context": "http://www.w3.org/ns/hydra/context.jsonld", + "@type": "PagedCollection", + "itemsPerPage": 30, + "totalItems": 5, + "member": [{ + "@id": "https://io.uitdatabank.be/organizers/6c972750-9f1a-4064-b517-620100e85196", + "@context": "/contexts/organizer", + "mainLanguage": "nl", + "url": "http://www.mediaraven.be", + "name": { + "nl": "Mediaraven" + }, + "created": "2017-01-31T17:10:38+00:00", + "creator": "1fb7638e-a2db-4fca-811c-67b84fed8d7c", + "workflowStatus": "ACTIVE", + "languages": [ + "nl" + ], + "completedLanguages": [ + "nl" + ], + "modified": "2019-05-15T09:05:53+00:00", + "labels": [ + "cultuurkuur_Actief Burgerschap", + "cultuurkuur_taal", + "cultuurkuur_Media" + ], + "contactPoint": { + "phone": [ + "092318270" + ], + "email": [ + "vorming@mediaraven.be" + ], + "url": [ + "www.mediaraven.be", + "www.facebook.com/mediaraven", + "twitter.com/mediaraven", + "www.youtube.com/mediaravenvzw" + ] + }, + "hiddenLabels": [ + "Specifiek voor jongeren" + ], + "regions": [ + "nis-44021", + "nis-44021-Z", + "nis-40000", + "reg-gent" + ], + "images": [{ + "@id": "https://io.uitdatabank.be/images/4a8d3301-3155-4e9d-aa61-f6f9c29ed992", + "contentUrl": "https://images.uitdatabank.be/4a8d3301-3155-4e9d-aa61-f6f9c29ed992.jpeg", + "thumbnailUrl": "https://images.uitdatabank.be/4a8d3301-3155-4e9d-aa61-f6f9c29ed992.jpeg", + "description": "Mediaraven", + "copyrightHolder": "Mediaraven", + "language": "nl" + }, + { + "@id": "https://io.uitdatabank.be/images/75ade23f-6b95-4136-9ec2-ae245324dfcc", + "contentUrl": "https://images.uitdatabank.be/75ade23f-6b95-4136-9ec2-ae245324dfcc.png", + "thumbnailUrl": "https://images.uitdatabank.be/75ade23f-6b95-4136-9ec2-ae245324dfcc.png", + "description": "Mediaraven logo detail", + "copyrightHolder": "Mediaraven", + "language": "nl" + } + ], + "image": "https://images.uitdatabank.be/4a8d3301-3155-4e9d-aa61-f6f9c29ed992.jpeg" + }, + { + "@id": "https://io.uitdatabank.be/organizers/b60f9f75-5c8e-41ef-b665-b9ad9aedac05", + "@context": "/contexts/organizer", + "mainLanguage": "nl", + "url": "http://www.kunstinzicht.be", + "name": { + "nl": "Kunst in Zicht" + }, + "created": "2017-09-04T08:42:47+00:00", + "creator": "96b44880-7137-4d9c-895b-ec54b09ffe2d", + "workflowStatus": "ACTIVE", + "description": { + "nl": "Kunst in Zicht ontwikkelt actieve kunsteducatieve projecten. In een labowerking voor kinderen en jongeren én tijdens vorming en coaching van hun begeleiders staan twee doelen voorop: leren door de kunsten én interesse ontwikkelen voor de kunsten.", + "fr": "Description française", + "en": "Description in English", + "de": "Deutsche Beschreibung" + }, + "languages": [ + "nl" + ], + "completedLanguages": [ + "nl" + ], + "modified": "2017-09-04T08:42:47+00:00", + "address": { + "nl": { + "addressCountry": "BE", + "addressLocality": "Turnhout", + "postalCode": "2300", + "streetAddress": "Warandestraat 42" + } + }, + "labels": [ + "cultuurkuur_kunst-en-cultuur", + "cultuurkuur_taal", + "cultuurkuur_Media" + ], + "contactPoint": { + "phone": [ + "014 47 23 35" + ], + "email": [ + "info@kunstinzicht.be" + ], + "url": [ + "http://www.kunstinzicht.be", + "www.facebook.com/kunstinzichtvzw" + ] + }, + "geo": { + "latitude": 51.324028, + "longitude": 4.94344 + }, + "regions": [ + "nis-10000", + "nis-13040", + "nis-13040A", + "reg-kempen" + ], + "images": [{ + "@id": "https://io.uitdatabank.be/images/546a90cd-a238-417b-aa98-1b6c50c1345c", + "contentUrl": "https://images.uitdatabank.be/546a90cd-a238-417b-aa98-1b6c50c1345c.jpeg", + "thumbnailUrl": "https://images.uitdatabank.be/546a90cd-a238-417b-aa98-1b6c50c1345c.jpeg", + "description": "Kunst in Zicht - Vrijhaven voor actieve kunsteducatie", + "copyrightHolder": "Kunst in Zicht", + "language": "nl" + }], + "image": "https://images.uitdatabank.be/546a90cd-a238-417b-aa98-1b6c50c1345c.jpeg" + }, + { + "@id": "https://io.uitdatabank.be/organizers/6C114F25-95D7-860D-E3479C3232046ADF", + "@context": "/contexts/organizer", + "mainLanguage": "nl", + "name": { + "nl": "Mooss vzw" + }, + "address": { + "nl": { + "addressCountry": "BE", + "addressLocality": "Leuven", + "postalCode": "3000", + "streetAddress": "Vaartkom 4" + } + }, + "labels": [ + "cultuurkuur_Actief Burgerschap", + "cultuurkuur_kunst-en-cultuur" + ], + "contactPoint": { + "phone": [ + "+32 16 65 94 65", + "016 65 94 65" + ], + "email": [ + "info@mooss.org" + ], + "url": [ + "www.mooss.org/", + "www.schoolmetcultuur.be/" + ] + }, + "workflowStatus": "ACTIVE", + "description": { + "nl": "Mooss vzw staat in Vlaanderen synoniem voor 'actieve kunst- en erfgoededucatie'. Het voornaamste doel is kinderen, jongeren en hun begeleiders goesting geven in kunst & erfgoed. Dat doen we via workshops, vormingen, bemiddeling en participatie. Wij werken binnen het jeugdwerk, erfgoedinstellingen, kunst- en cultuurcentra, bibliotheken, onderwijsinstellingen...", + "fr": "Description française", + "en": "Description in English", + "de": "Deutsche Beschreibung" + }, + "languages": [ + "nl" + ], + "completedLanguages": [ + "nl" + ], + "modified": "2020-01-11T03:36:08+00:00", + "hiddenLabels": [ + "UiTPAS Leuven", + "RO_Kunsteducatief gesubsidieerd", + "Specifiek voor jongeren", + "UiTPAS Gent", + "UiTPAS Regio Aalst" + ], + "url": "http://www.mooss.org", + "geo": { + "latitude": 50.8875824, + "longitude": 4.7002225 + }, + "regions": [ + "nis-24062A", + "nis-20001", + "reg-leuven", + "nis-24062" + ] + }, + { + "@id": "https://io.uitdatabank.be/organizers/8fbfaf6f-bec1-4912-8895-51c40570a7ee", + "@context": "/contexts/organizer", + "mainLanguage": "nl", + "url": "https://www.artforum.be/nl/contact", + "name": { + "nl": "Artforum" + }, + "address": { + "nl": { + "addressCountry": "BE", + "addressLocality": "Leuven", + "postalCode": "3000", + "streetAddress": "Stapelhuisstraat 13" + } + }, + "created": "2019-04-18T15:05:54+00:00", + "creator": "cd4235e0-f4d2-4a3c-a9a8-90a705ab86ab", + "labels": [ + "cultuurkuur_Actief Burgerschap", + "cultuurkuur_kunst-en-cultuur", + "cultuurkuur_Duurzaamheid, natuur en milieu", + "cultuurkuur_taal" + ], + "contactPoint": { + "phone": [ + "016.24 66 24" + ], + "email": [ + "info@artforum.be" + ], + "url": [ + "www.artforum.be", + "www.schoolmetcultuur.be/", + "www.facebook.com/artforumvzw" + ] + }, + "workflowStatus": "ACTIVE", + "description": { + "nl": "Artforum is een kunsteducatieve organisatie die zich richt tot kinderen en jongeren van 3 tot 25 jaar. We werken altijd met kinderen en jongeren, kunstenaars en rond maatschappelijke thema's.", + "fr": "Description française", + "en": "Description in English", + "de": "Deutsche Beschreibung" + }, + "languages": [ + "nl" + ], + "completedLanguages": [ + "nl" + ], + "modified": "2019-10-30T11:08:49+00:00", + "geo": { + "latitude": 50.8866322, + "longitude": 4.7051347 + }, + "regions": [ + "nis-24062A", + "nis-20001", + "reg-leuven", + "nis-24062" + ] + }, + { + "@id": "https://io.uitdatabank.be/organizers/CCEB27E3-AB71-99D0-D3E3C0E388CDDEED", + "@context": "/contexts/organizer", + "mainLanguage": "nl", + "name": { + "nl": "Villa Basta" + }, + "address": { + "nl": { + "addressCountry": "BE", + "addressLocality": "Hasselt", + "postalCode": "3500", + "streetAddress": "Vissersstraat 2E" + } + }, + "labels": [ + "mijnkindopkamp", + "cultuurkuur_Actief Burgerschap", + "cultuurkuur_kunst-en-cultuur", + "cultuurkuur_Duurzaamheid, natuur en milieu", + "cultuurkuur_taal", + "cultuurkuur_Leren leren", + "cultuurkuur_Ondernemingszin", + "cultuurkuur_Lichamelijke, sociale en mentale gezondheid" + ], + "contactPoint": { + "phone": [ + "+32 11 72 77 77" + ], + "email": [ + "info@villabasta.be" + ], + "url": [ + "www.villabasta.be", + "www.facebook.com/villabasta", + "twitter.com/VillaBasta", + "www.youtube.com/user/VillaBasta" + ] + }, + "workflowStatus": "ACTIVE", + "description": { + "nl": "Villa Basta vzw organiseert creatieve workshops en projecten op locatie in heel Vlaanderen. Binnen de domeinen THEATER, DANS, VIDEO, MUZIEK EN BEELD bieden we creatieve activiteiten op maat aan voor kinderen, tieners en jongvolwassenen.", + "fr": "Description française", + "en": "Description in English", + "de": "Deutsche Beschreibung" + }, + "languages": [ + "nl" + ], + "completedLanguages": [ + "nl" + ], + "modified": "2021-05-27T07:26:13+00:00", + "hiddenLabels": [ + "Specifiek voor jongeren", + "UiTPAS 26", + "RO_Jeugdinitiatief" + ], + "url": "https://villabasta.be/", + "geo": { + "latitude": 50.9385821, + "longitude": 5.3542212 + }, + "regions": [ + "nis-71022", + "nis-71022A", + "reg-hasselt", + "nis-70000" + ] + } + ], + "facet": { + "regions": { + "nis-70000": { + "name": { + "nl": "Provincie Limburg", + "fr": "Province du Limbourg", + "de": "Provinz Limburg" + }, + "count": 1, + "children": { + "reg-hasselt": { + "name": { + "nl": "Hasselt" + }, + "count": 1, + "children": { + "nis-71022": { + "name": { + "nl": "Hasselt" + }, + "count": 1, + "children": { + "nis-71022A": { + "name": { + "nl": "Hasselt" + }, + "count": 1 + } + } + } + } + } + } + }, + "nis-10000": { + "name": { + "nl": "Provincie Antwerpen", + "fr": "Province d'Anvers", + "de": "Provinz Antwerpen" + }, + "count": 1, + "children": { + "reg-kempen": { + "name": { + "nl": "Kempen" + }, + "count": 1, + "children": { + "nis-24062": { + "name": { + "nl": "Turnhout" + }, + "count": 1, + "children": { + "nis-24062A": { + "name": { + "nl": "Turnhout" + }, + "count": 1 + } + } + } + } + } + } + }, + "nis-20001": { + "name": { + "nl": "Provincie Vlaams-Brabant", + "fr": "Province du Brabant flamand", + "de": "Provinz Flämisch-Brabant" + }, + "count": 1, + "children": { + "reg-leuven": { + "name": { + "nl": "Leuven" + }, + "count": 1, + "children": { + "nis-24062": { + "name": { + "nl": "Leuven" + }, + "count": 1, + "children": { + "nis-24062A": { + "name": { + "nl": "Leuven" + }, + "count": 1 + } + } + } + } + } + } + }, + "nis-40000": { + "name": { + "nl": "Provincie Oost-Vlaanderen", + "fr": "Province de Flandre orientale", + "de": "Provinz Ostflandern" + }, + "count": 1, + "children": { + "reg-gent": { + "name": { + "nl": "Gent" + }, + "count": 1, + "children": { + "nis-44021": { + "name": { + "nl": "Gent" + }, + "count": 1, + "children": { + "nis-44021-Z": { + "name": { + "nl": "Gent" + }, + "count": 1 + } + } + } + } + } + } + } + } + } +} diff --git a/src/SearchClient.php b/src/SearchClient.php index f3153da3..bc50004c 100644 --- a/src/SearchClient.php +++ b/src/SearchClient.php @@ -51,14 +51,23 @@ public function searchOffers(SearchQueryInterface $searchQuery): PagedCollection return $this->search($searchQuery, 'offers'); } + public function searchOrganizers(SearchQueryInterface $searchQuery): PagedCollection + { + return $this->search($searchQuery, 'organizers'); + } + private function search(SearchQueryInterface $searchQuery, $type): PagedCollection { $options = [ 'query' => $searchQuery->toArray(), ]; - $result = $this->client->request('GET', $type, $options); + // @todo: Remove when the organizers endpoint is functioning. + if ($type == 'organizers') { + return $this->serializer->deserialize(file_get_contents(__DIR__ . '/../data/organizers.json')); + } + $result = $this->client->request('GET', $type, $options); return $this->serializer->deserialize((string) $result->getBody()); } } diff --git a/src/SearchClientInterface.php b/src/SearchClientInterface.php index 59136de3..5e31ccda 100644 --- a/src/SearchClientInterface.php +++ b/src/SearchClientInterface.php @@ -18,4 +18,6 @@ public function searchEvents(SearchQueryInterface $searchQuery): PagedCollection public function searchPlaces(SearchQueryInterface $searchQuery): PagedCollection; public function searchOffers(SearchQueryInterface $searchQuery): PagedCollection; + + public function searchOrganizers(SearchQueryInterface $searchQuery): PagedCollection; } diff --git a/src/ValueObjects/Collection.php b/src/ValueObjects/Collection.php index d39eef82..fd035f81 100644 --- a/src/ValueObjects/Collection.php +++ b/src/ValueObjects/Collection.php @@ -14,11 +14,13 @@ final class Collection private $contextMapping = [ '/contexts/event' => Event::class, '/contexts/place' => Place::class, + '/contexts/organizer' => Organizer::class, ]; private $typeMapping = [ 'Event' => Event::class, 'Place' => Place::class, + 'Organizer' => Organizer::class, ]; private $items = []; diff --git a/src/ValueObjects/Image.php b/src/ValueObjects/Image.php new file mode 100644 index 00000000..b949a2ce --- /dev/null +++ b/src/ValueObjects/Image.php @@ -0,0 +1,108 @@ +id; + } + + public function setId(string $id): void + { + $this->id = $id; + } + + public function getLanguage(): string + { + return $this->language; + } + + public function setLanguage(string $language): void + { + $this->language = $language; + } + + public function getContentUrl(): string + { + return $this->contentUrl; + } + + public function setContentUrl(string $contentUrl): void + { + $this->contentUrl = $contentUrl; + } + + public function getThumbnailUrl(): string + { + return $this->thumbnailUrl; + } + + public function setThumbnailUrl(string $thumbnailUrl): void + { + $this->thumbnailUrl = $thumbnailUrl; + } + + public function getCopyrightHolder(): ?string + { + return $this->copyrightHolder; + } + + public function setCopyrightHolder(?string $copyrightHolder): void + { + $this->copyrightHolder = $copyrightHolder; + } + + public function getDescription(): ?string + { + return $this->description; + } + + public function setDescription(?string $description): void + { + $this->description = $description; + } +} diff --git a/src/ValueObjects/Organizer.php b/src/ValueObjects/Organizer.php index 786f38b9..3b37e61c 100644 --- a/src/ValueObjects/Organizer.php +++ b/src/ValueObjects/Organizer.php @@ -23,10 +23,58 @@ final class Organizer private $name; /** - * @var string[] + * @var string|null + * @Type("string") + */ + private $mainLanguage; + + /** + * @var string|null + * @Type("string") + */ + private $url; + + /** + * @var string|null + * @Type("string") + */ + private $creator; + + /** + * @var DateTime|null + * @Type("DateTime") + */ + private $created; + + /** + * @var string|null + * @Type("string") + */ + private $workflowStatus; + + /** + * @var array * @Type("array") */ - private $email = []; + private $languages = []; + + /** + * @var array + * @Type("array") + */ + private $completedLanguages = []; + + /** + * @var DateTime|null + * @Type("DateTime") + */ + private $modified; + + /** + * @var array + * @Type("array") + */ + private $labels = []; /** * @var ContactPoint|null @@ -40,6 +88,42 @@ final class Organizer */ private $hiddenLabels = []; + /** + * @var array + * @Type("array") + */ + private $regions = []; + + /** + * @var string|null + * @Type("string") + */ + private $image; + + /** + * @var TranslatedAddress|null + * @Type("CultuurNet\SearchV3\ValueObjects\TranslatedAddress") + */ + private $address; + + /** + * @var GeoPoint + * @Type("CultuurNet\SearchV3\ValueObjects\GeoPoint") + */ + private $geo; + + /** + * @var TranslatedString|null + * @Type("CultuurNet\SearchV3\ValueObjects\TranslatedString") + */ + private $description; + + /** + * @var array + * @Type("array") + */ + private $images = []; + public function getId(): ?string { return $this->id; @@ -90,19 +174,163 @@ public function setContactPoint(ContactPoint $contactPoint): void $this->contactPoint = $contactPoint; } - /** - * @return string[] - */ public function getHiddenLabels(): array { return $this->hiddenLabels; } - /** - * @param string[] $hiddenLabels - */ public function setHiddenLabels(array $hiddenLabels): void { $this->hiddenLabels = $hiddenLabels; } + + public function getAddress(): ?TranslatedAddress + { + return $this->address; + } + + public function setAddress(TranslatedAddress $address): void + { + $this->address = $address; + } + + public function getGeo(): ?GeoPoint + { + return $this->geo; + } + + public function setGeo(GeoPoint $geo): void + { + $this->geo = $geo; + } + + public function getMainLanguage(): ?string + { + return $this->mainLanguage; + } + + public function setMainLanguage(?string $mainLanguage): void + { + $this->mainLanguage = $mainLanguage; + } + + public function getUrl(): ?string + { + return $this->url; + } + + public function setUrl(?string $url): void + { + $this->url = $url; + } + + public function getCreator(): ?string + { + return $this->creator; + } + + public function setCreator(?string $creator): void + { + $this->creator = $creator; + } + + public function getCreated(): ?DateTime + { + return $this->created; + } + + public function setCreated(?DateTime $created): void + { + $this->created = $created; + } + + public function getWorkflowStatus(): ?string + { + return $this->workflowStatus; + } + + public function setWorkflowStatus(?string $workflowStatus): void + { + $this->workflowStatus = $workflowStatus; + } + + public function getLanguages(): array + { + return $this->languages; + } + + public function setLanguages(array $languages): void + { + $this->languages = $languages; + } + + public function getCompletedLanguages(): array + { + return $this->completedLanguages; + } + + public function setCompletedLanguages(array $completedLanguages): void + { + $this->completedLanguages = $completedLanguages; + } + + public function getModified(): ?DateTime + { + return $this->modified; + } + + public function setModified(?DateTime $modified): void + { + $this->modified = $modified; + } + + public function getLabels(): array + { + return $this->labels; + } + + public function setLabels(array $labels): void + { + $this->labels = $labels; + } + + public function getRegions(): array + { + return $this->regions; + } + + public function setRegions(array $regions): void + { + $this->regions = $regions; + } + + public function getImage(): ?string + { + return $this->image; + } + + public function setImage(?string $image): void + { + $this->image = $image; + } + + public function getDescription(): ?TranslatedString + { + return $this->description; + } + + public function setDescription(?TranslatedString $description): void + { + $this->description = $description; + } + + public function getImages(): array + { + return $this->images; + } + + public function setImages(array $images): void + { + $this->images = $images; + } } From f75576934ac2084849f8a2df7e01dc0299839f22 Mon Sep 17 00:00:00 2001 From: Wouter Vanelslander Date: Thu, 13 Jan 2022 14:46:05 +0100 Subject: [PATCH 02/13] PUBLIQ-499: Removed "Image" and use "MediaObject" in place --- src/ValueObjects/Image.php | 108 --------------------------------- src/ValueObjects/Organizer.php | 2 +- 2 files changed, 1 insertion(+), 109 deletions(-) delete mode 100644 src/ValueObjects/Image.php diff --git a/src/ValueObjects/Image.php b/src/ValueObjects/Image.php deleted file mode 100644 index b949a2ce..00000000 --- a/src/ValueObjects/Image.php +++ /dev/null @@ -1,108 +0,0 @@ -id; - } - - public function setId(string $id): void - { - $this->id = $id; - } - - public function getLanguage(): string - { - return $this->language; - } - - public function setLanguage(string $language): void - { - $this->language = $language; - } - - public function getContentUrl(): string - { - return $this->contentUrl; - } - - public function setContentUrl(string $contentUrl): void - { - $this->contentUrl = $contentUrl; - } - - public function getThumbnailUrl(): string - { - return $this->thumbnailUrl; - } - - public function setThumbnailUrl(string $thumbnailUrl): void - { - $this->thumbnailUrl = $thumbnailUrl; - } - - public function getCopyrightHolder(): ?string - { - return $this->copyrightHolder; - } - - public function setCopyrightHolder(?string $copyrightHolder): void - { - $this->copyrightHolder = $copyrightHolder; - } - - public function getDescription(): ?string - { - return $this->description; - } - - public function setDescription(?string $description): void - { - $this->description = $description; - } -} diff --git a/src/ValueObjects/Organizer.php b/src/ValueObjects/Organizer.php index 3b37e61c..03a120a2 100644 --- a/src/ValueObjects/Organizer.php +++ b/src/ValueObjects/Organizer.php @@ -120,7 +120,7 @@ final class Organizer /** * @var array - * @Type("array") + * @Type("array") */ private $images = []; From 3f48fcd0be1290e84a1eb0fa335459d71f3912fe Mon Sep 17 00:00:00 2001 From: Nils Destoop Date: Fri, 14 Jan 2022 14:50:15 +0100 Subject: [PATCH 03/13] Fix datetime namespace + missing email property --- src/ValueObjects/Organizer.php | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/ValueObjects/Organizer.php b/src/ValueObjects/Organizer.php index 03a120a2..8b88ddba 100644 --- a/src/ValueObjects/Organizer.php +++ b/src/ValueObjects/Organizer.php @@ -41,7 +41,7 @@ final class Organizer private $creator; /** - * @var DateTime|null + * @var \DateTime|null * @Type("DateTime") */ private $created; @@ -65,7 +65,7 @@ final class Organizer private $completedLanguages = []; /** - * @var DateTime|null + * @var \DateTime|null * @Type("DateTime") */ private $modified; @@ -76,6 +76,11 @@ final class Organizer */ private $labels = []; + /** + * @var string + */ + private $email; + /** * @var ContactPoint|null * @Type("CultuurNet\SearchV3\ValueObjects\ContactPoint") @@ -234,12 +239,12 @@ public function setCreator(?string $creator): void $this->creator = $creator; } - public function getCreated(): ?DateTime + public function getCreated(): ?\DateTime { return $this->created; } - public function setCreated(?DateTime $created): void + public function setCreated(?\DateTime $created): void { $this->created = $created; } @@ -274,12 +279,12 @@ public function setCompletedLanguages(array $completedLanguages): void $this->completedLanguages = $completedLanguages; } - public function getModified(): ?DateTime + public function getModified(): ?\DateTime { return $this->modified; } - public function setModified(?DateTime $modified): void + public function setModified(?\DateTime $modified): void { $this->modified = $modified; } From e83611895a7342363f3a52c0c75ed3cf32ac483a Mon Sep 17 00:00:00 2001 From: Nils Destoop Date: Fri, 14 Jan 2022 14:58:31 +0100 Subject: [PATCH 04/13] PUBLIQ-499: Fix phpcs errors and phpstan errors --- src/SearchClient.php | 4 +-- src/ValueObjects/Organizer.php | 63 +++++++++++++++++----------------- 2 files changed, 34 insertions(+), 33 deletions(-) diff --git a/src/SearchClient.php b/src/SearchClient.php index bc50004c..26c25a92 100644 --- a/src/SearchClient.php +++ b/src/SearchClient.php @@ -53,7 +53,7 @@ public function searchOffers(SearchQueryInterface $searchQuery): PagedCollection public function searchOrganizers(SearchQueryInterface $searchQuery): PagedCollection { - return $this->search($searchQuery, 'organizers'); + return $this->search($searchQuery, 'organizers'); } private function search(SearchQueryInterface $searchQuery, $type): PagedCollection @@ -64,7 +64,7 @@ private function search(SearchQueryInterface $searchQuery, $type): PagedCollecti // @todo: Remove when the organizers endpoint is functioning. if ($type == 'organizers') { - return $this->serializer->deserialize(file_get_contents(__DIR__ . '/../data/organizers.json')); + return $this->serializer->deserialize(file_get_contents(__DIR__ . '/../data/organizers.json')); } $result = $this->client->request('GET', $type, $options); diff --git a/src/ValueObjects/Organizer.php b/src/ValueObjects/Organizer.php index 8b88ddba..36940626 100644 --- a/src/ValueObjects/Organizer.php +++ b/src/ValueObjects/Organizer.php @@ -77,7 +77,8 @@ final class Organizer private $labels = []; /** - * @var string + * @var array + * @Type("array") */ private $email; @@ -191,151 +192,151 @@ public function setHiddenLabels(array $hiddenLabels): void public function getAddress(): ?TranslatedAddress { - return $this->address; + return $this->address; } public function setAddress(TranslatedAddress $address): void { - $this->address = $address; + $this->address = $address; } public function getGeo(): ?GeoPoint { - return $this->geo; + return $this->geo; } public function setGeo(GeoPoint $geo): void { - $this->geo = $geo; + $this->geo = $geo; } public function getMainLanguage(): ?string { - return $this->mainLanguage; + return $this->mainLanguage; } public function setMainLanguage(?string $mainLanguage): void { - $this->mainLanguage = $mainLanguage; + $this->mainLanguage = $mainLanguage; } public function getUrl(): ?string { - return $this->url; + return $this->url; } public function setUrl(?string $url): void { - $this->url = $url; + $this->url = $url; } public function getCreator(): ?string { - return $this->creator; + return $this->creator; } public function setCreator(?string $creator): void { - $this->creator = $creator; + $this->creator = $creator; } public function getCreated(): ?\DateTime { - return $this->created; + return $this->created; } public function setCreated(?\DateTime $created): void { - $this->created = $created; + $this->created = $created; } public function getWorkflowStatus(): ?string { - return $this->workflowStatus; + return $this->workflowStatus; } public function setWorkflowStatus(?string $workflowStatus): void { - $this->workflowStatus = $workflowStatus; + $this->workflowStatus = $workflowStatus; } public function getLanguages(): array { - return $this->languages; + return $this->languages; } public function setLanguages(array $languages): void { - $this->languages = $languages; + $this->languages = $languages; } public function getCompletedLanguages(): array { - return $this->completedLanguages; + return $this->completedLanguages; } public function setCompletedLanguages(array $completedLanguages): void { - $this->completedLanguages = $completedLanguages; + $this->completedLanguages = $completedLanguages; } public function getModified(): ?\DateTime { - return $this->modified; + return $this->modified; } public function setModified(?\DateTime $modified): void { - $this->modified = $modified; + $this->modified = $modified; } public function getLabels(): array { - return $this->labels; + return $this->labels; } public function setLabels(array $labels): void { - $this->labels = $labels; + $this->labels = $labels; } public function getRegions(): array { - return $this->regions; + return $this->regions; } public function setRegions(array $regions): void { - $this->regions = $regions; + $this->regions = $regions; } public function getImage(): ?string { - return $this->image; + return $this->image; } public function setImage(?string $image): void { - $this->image = $image; + $this->image = $image; } public function getDescription(): ?TranslatedString { - return $this->description; + return $this->description; } public function setDescription(?TranslatedString $description): void { - $this->description = $description; + $this->description = $description; } public function getImages(): array { - return $this->images; + return $this->images; } public function setImages(array $images): void { - $this->images = $images; + $this->images = $images; } } From 34b4a4a854c2e6202bede56a0031dad5ba261d58 Mon Sep 17 00:00:00 2001 From: Nils Destoop Date: Fri, 14 Jan 2022 15:17:24 +0100 Subject: [PATCH 05/13] PUBLIQ-499: Update the serializer test --- test/Serializer/SerializerTest.php | 15 +++++++++++++++ .../data/search-with-embed-and-facets.json | 8 +++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/test/Serializer/SerializerTest.php b/test/Serializer/SerializerTest.php index 403ef735..403c2a01 100644 --- a/test/Serializer/SerializerTest.php +++ b/test/Serializer/SerializerTest.php @@ -288,11 +288,26 @@ public function testDeserializeMethodForResultsWithEmbedAndFacets(): void $organizer->setName(new TranslatedString([ 'nl' => 'Constant vzw', ])); + $organizer->setMainLanguage('nl'); + $organizer->setLanguages(['nl']); + $organizer->setCompletedLanguages(['nl']); + $organizer->setUrl('http://constantvzw.org'); + $organizer->setCreator('618d65f9-641c-4697-8fd8-436dabaebd2e'); + $organizer->setWorkflowStatus('ACTIVE'); + $organizer->setCreated(new \DateTime('2018-05-09T12:32:39+00:00')); + $organizer->setModified(new \DateTime('2018-05-09T12:32:39+00:00')); $organizerContactPoint = new ContactPoint(); $organizerContactPoint->setEmails(['info@constantvzw.org']); $organizer->setContactPoint($organizerContactPoint); + $organizerAddresses = new TranslatedAddress(); + $organizerAddresses->setAddresses([ + 'nl' => $addressNl, + 'fr' => $addressFr, + ]); + $organizer->setAddress($organizerAddresses); + $event->setOrganizer($organizer); $expectedMember = new Collection(); diff --git a/test/Serializer/data/search-with-embed-and-facets.json b/test/Serializer/data/search-with-embed-and-facets.json index abc07de9..7cc398aa 100644 --- a/test/Serializer/data/search-with-embed-and-facets.json +++ b/test/Serializer/data/search-with-embed-and-facets.json @@ -212,9 +212,15 @@ "address": { "nl": { "addressCountry": "BE", - "addressLocality": "Sint-Gillis (Brussel)", + "addressLocality": "Sint-Gillis", "postalCode": "1060", "streetAddress": "Fortstraat 5" + }, + "fr": { + "addressCountry": "BE", + "addressLocality": "Saint-Gilles", + "postalCode": "1060", + "streetAddress": "Rue du Fort 5" } }, "contactPoint": { From 1f1ba9991f08d14a228976c83b3fcf1fc0e81a8d Mon Sep 17 00:00:00 2001 From: Nils Destoop Date: Fri, 21 Jan 2022 14:30:53 +0100 Subject: [PATCH 06/13] Add address and description for first organizer --- data/organizers.json | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/data/organizers.json b/data/organizers.json index e8e2a485..8e9b3de0 100644 --- a/data/organizers.json +++ b/data/organizers.json @@ -49,6 +49,20 @@ "nis-40000", "reg-gent" ], + "address": { + "nl": { + "addressCountry": "BE", + "addressLocality": "Turnhout", + "postalCode": "2300", + "streetAddress": "Warandestraat 42" + } + }, + "description": { + "nl": "Villa Basta vzw organiseert creatieve workshops en projecten op locatie in heel Vlaanderen. Binnen de domeinen THEATER, DANS, VIDEO, MUZIEK EN BEELD bieden we creatieve activiteiten op maat aan voor kinderen, tieners en jongvolwassenen.", + "fr": "Description française", + "en": "Description in English", + "de": "Deutsche Beschreibung" + }, "images": [{ "@id": "https://io.uitdatabank.be/images/4a8d3301-3155-4e9d-aa61-f6f9c29ed992", "contentUrl": "https://images.uitdatabank.be/4a8d3301-3155-4e9d-aa61-f6f9c29ed992.jpeg", From 7cf741dd6ed29e9a1db95d4943bf76e4c8a894c7 Mon Sep 17 00:00:00 2001 From: Wouter Vanelslander Date: Wed, 16 Feb 2022 09:45:18 +0100 Subject: [PATCH 07/13] PUBLIQ-499: Removed dummy data --- data/organizers.json | 470 ------------------------------------------- src/SearchClient.php | 5 - 2 files changed, 475 deletions(-) delete mode 100644 data/organizers.json diff --git a/data/organizers.json b/data/organizers.json deleted file mode 100644 index e8e2a485..00000000 --- a/data/organizers.json +++ /dev/null @@ -1,470 +0,0 @@ -{ - "@context": "http://www.w3.org/ns/hydra/context.jsonld", - "@type": "PagedCollection", - "itemsPerPage": 30, - "totalItems": 5, - "member": [{ - "@id": "https://io.uitdatabank.be/organizers/6c972750-9f1a-4064-b517-620100e85196", - "@context": "/contexts/organizer", - "mainLanguage": "nl", - "url": "http://www.mediaraven.be", - "name": { - "nl": "Mediaraven" - }, - "created": "2017-01-31T17:10:38+00:00", - "creator": "1fb7638e-a2db-4fca-811c-67b84fed8d7c", - "workflowStatus": "ACTIVE", - "languages": [ - "nl" - ], - "completedLanguages": [ - "nl" - ], - "modified": "2019-05-15T09:05:53+00:00", - "labels": [ - "cultuurkuur_Actief Burgerschap", - "cultuurkuur_taal", - "cultuurkuur_Media" - ], - "contactPoint": { - "phone": [ - "092318270" - ], - "email": [ - "vorming@mediaraven.be" - ], - "url": [ - "www.mediaraven.be", - "www.facebook.com/mediaraven", - "twitter.com/mediaraven", - "www.youtube.com/mediaravenvzw" - ] - }, - "hiddenLabels": [ - "Specifiek voor jongeren" - ], - "regions": [ - "nis-44021", - "nis-44021-Z", - "nis-40000", - "reg-gent" - ], - "images": [{ - "@id": "https://io.uitdatabank.be/images/4a8d3301-3155-4e9d-aa61-f6f9c29ed992", - "contentUrl": "https://images.uitdatabank.be/4a8d3301-3155-4e9d-aa61-f6f9c29ed992.jpeg", - "thumbnailUrl": "https://images.uitdatabank.be/4a8d3301-3155-4e9d-aa61-f6f9c29ed992.jpeg", - "description": "Mediaraven", - "copyrightHolder": "Mediaraven", - "language": "nl" - }, - { - "@id": "https://io.uitdatabank.be/images/75ade23f-6b95-4136-9ec2-ae245324dfcc", - "contentUrl": "https://images.uitdatabank.be/75ade23f-6b95-4136-9ec2-ae245324dfcc.png", - "thumbnailUrl": "https://images.uitdatabank.be/75ade23f-6b95-4136-9ec2-ae245324dfcc.png", - "description": "Mediaraven logo detail", - "copyrightHolder": "Mediaraven", - "language": "nl" - } - ], - "image": "https://images.uitdatabank.be/4a8d3301-3155-4e9d-aa61-f6f9c29ed992.jpeg" - }, - { - "@id": "https://io.uitdatabank.be/organizers/b60f9f75-5c8e-41ef-b665-b9ad9aedac05", - "@context": "/contexts/organizer", - "mainLanguage": "nl", - "url": "http://www.kunstinzicht.be", - "name": { - "nl": "Kunst in Zicht" - }, - "created": "2017-09-04T08:42:47+00:00", - "creator": "96b44880-7137-4d9c-895b-ec54b09ffe2d", - "workflowStatus": "ACTIVE", - "description": { - "nl": "Kunst in Zicht ontwikkelt actieve kunsteducatieve projecten. In een labowerking voor kinderen en jongeren én tijdens vorming en coaching van hun begeleiders staan twee doelen voorop: leren door de kunsten én interesse ontwikkelen voor de kunsten.", - "fr": "Description française", - "en": "Description in English", - "de": "Deutsche Beschreibung" - }, - "languages": [ - "nl" - ], - "completedLanguages": [ - "nl" - ], - "modified": "2017-09-04T08:42:47+00:00", - "address": { - "nl": { - "addressCountry": "BE", - "addressLocality": "Turnhout", - "postalCode": "2300", - "streetAddress": "Warandestraat 42" - } - }, - "labels": [ - "cultuurkuur_kunst-en-cultuur", - "cultuurkuur_taal", - "cultuurkuur_Media" - ], - "contactPoint": { - "phone": [ - "014 47 23 35" - ], - "email": [ - "info@kunstinzicht.be" - ], - "url": [ - "http://www.kunstinzicht.be", - "www.facebook.com/kunstinzichtvzw" - ] - }, - "geo": { - "latitude": 51.324028, - "longitude": 4.94344 - }, - "regions": [ - "nis-10000", - "nis-13040", - "nis-13040A", - "reg-kempen" - ], - "images": [{ - "@id": "https://io.uitdatabank.be/images/546a90cd-a238-417b-aa98-1b6c50c1345c", - "contentUrl": "https://images.uitdatabank.be/546a90cd-a238-417b-aa98-1b6c50c1345c.jpeg", - "thumbnailUrl": "https://images.uitdatabank.be/546a90cd-a238-417b-aa98-1b6c50c1345c.jpeg", - "description": "Kunst in Zicht - Vrijhaven voor actieve kunsteducatie", - "copyrightHolder": "Kunst in Zicht", - "language": "nl" - }], - "image": "https://images.uitdatabank.be/546a90cd-a238-417b-aa98-1b6c50c1345c.jpeg" - }, - { - "@id": "https://io.uitdatabank.be/organizers/6C114F25-95D7-860D-E3479C3232046ADF", - "@context": "/contexts/organizer", - "mainLanguage": "nl", - "name": { - "nl": "Mooss vzw" - }, - "address": { - "nl": { - "addressCountry": "BE", - "addressLocality": "Leuven", - "postalCode": "3000", - "streetAddress": "Vaartkom 4" - } - }, - "labels": [ - "cultuurkuur_Actief Burgerschap", - "cultuurkuur_kunst-en-cultuur" - ], - "contactPoint": { - "phone": [ - "+32 16 65 94 65", - "016 65 94 65" - ], - "email": [ - "info@mooss.org" - ], - "url": [ - "www.mooss.org/", - "www.schoolmetcultuur.be/" - ] - }, - "workflowStatus": "ACTIVE", - "description": { - "nl": "Mooss vzw staat in Vlaanderen synoniem voor 'actieve kunst- en erfgoededucatie'. Het voornaamste doel is kinderen, jongeren en hun begeleiders goesting geven in kunst & erfgoed. Dat doen we via workshops, vormingen, bemiddeling en participatie. Wij werken binnen het jeugdwerk, erfgoedinstellingen, kunst- en cultuurcentra, bibliotheken, onderwijsinstellingen...", - "fr": "Description française", - "en": "Description in English", - "de": "Deutsche Beschreibung" - }, - "languages": [ - "nl" - ], - "completedLanguages": [ - "nl" - ], - "modified": "2020-01-11T03:36:08+00:00", - "hiddenLabels": [ - "UiTPAS Leuven", - "RO_Kunsteducatief gesubsidieerd", - "Specifiek voor jongeren", - "UiTPAS Gent", - "UiTPAS Regio Aalst" - ], - "url": "http://www.mooss.org", - "geo": { - "latitude": 50.8875824, - "longitude": 4.7002225 - }, - "regions": [ - "nis-24062A", - "nis-20001", - "reg-leuven", - "nis-24062" - ] - }, - { - "@id": "https://io.uitdatabank.be/organizers/8fbfaf6f-bec1-4912-8895-51c40570a7ee", - "@context": "/contexts/organizer", - "mainLanguage": "nl", - "url": "https://www.artforum.be/nl/contact", - "name": { - "nl": "Artforum" - }, - "address": { - "nl": { - "addressCountry": "BE", - "addressLocality": "Leuven", - "postalCode": "3000", - "streetAddress": "Stapelhuisstraat 13" - } - }, - "created": "2019-04-18T15:05:54+00:00", - "creator": "cd4235e0-f4d2-4a3c-a9a8-90a705ab86ab", - "labels": [ - "cultuurkuur_Actief Burgerschap", - "cultuurkuur_kunst-en-cultuur", - "cultuurkuur_Duurzaamheid, natuur en milieu", - "cultuurkuur_taal" - ], - "contactPoint": { - "phone": [ - "016.24 66 24" - ], - "email": [ - "info@artforum.be" - ], - "url": [ - "www.artforum.be", - "www.schoolmetcultuur.be/", - "www.facebook.com/artforumvzw" - ] - }, - "workflowStatus": "ACTIVE", - "description": { - "nl": "Artforum is een kunsteducatieve organisatie die zich richt tot kinderen en jongeren van 3 tot 25 jaar. We werken altijd met kinderen en jongeren, kunstenaars en rond maatschappelijke thema's.", - "fr": "Description française", - "en": "Description in English", - "de": "Deutsche Beschreibung" - }, - "languages": [ - "nl" - ], - "completedLanguages": [ - "nl" - ], - "modified": "2019-10-30T11:08:49+00:00", - "geo": { - "latitude": 50.8866322, - "longitude": 4.7051347 - }, - "regions": [ - "nis-24062A", - "nis-20001", - "reg-leuven", - "nis-24062" - ] - }, - { - "@id": "https://io.uitdatabank.be/organizers/CCEB27E3-AB71-99D0-D3E3C0E388CDDEED", - "@context": "/contexts/organizer", - "mainLanguage": "nl", - "name": { - "nl": "Villa Basta" - }, - "address": { - "nl": { - "addressCountry": "BE", - "addressLocality": "Hasselt", - "postalCode": "3500", - "streetAddress": "Vissersstraat 2E" - } - }, - "labels": [ - "mijnkindopkamp", - "cultuurkuur_Actief Burgerschap", - "cultuurkuur_kunst-en-cultuur", - "cultuurkuur_Duurzaamheid, natuur en milieu", - "cultuurkuur_taal", - "cultuurkuur_Leren leren", - "cultuurkuur_Ondernemingszin", - "cultuurkuur_Lichamelijke, sociale en mentale gezondheid" - ], - "contactPoint": { - "phone": [ - "+32 11 72 77 77" - ], - "email": [ - "info@villabasta.be" - ], - "url": [ - "www.villabasta.be", - "www.facebook.com/villabasta", - "twitter.com/VillaBasta", - "www.youtube.com/user/VillaBasta" - ] - }, - "workflowStatus": "ACTIVE", - "description": { - "nl": "Villa Basta vzw organiseert creatieve workshops en projecten op locatie in heel Vlaanderen. Binnen de domeinen THEATER, DANS, VIDEO, MUZIEK EN BEELD bieden we creatieve activiteiten op maat aan voor kinderen, tieners en jongvolwassenen.", - "fr": "Description française", - "en": "Description in English", - "de": "Deutsche Beschreibung" - }, - "languages": [ - "nl" - ], - "completedLanguages": [ - "nl" - ], - "modified": "2021-05-27T07:26:13+00:00", - "hiddenLabels": [ - "Specifiek voor jongeren", - "UiTPAS 26", - "RO_Jeugdinitiatief" - ], - "url": "https://villabasta.be/", - "geo": { - "latitude": 50.9385821, - "longitude": 5.3542212 - }, - "regions": [ - "nis-71022", - "nis-71022A", - "reg-hasselt", - "nis-70000" - ] - } - ], - "facet": { - "regions": { - "nis-70000": { - "name": { - "nl": "Provincie Limburg", - "fr": "Province du Limbourg", - "de": "Provinz Limburg" - }, - "count": 1, - "children": { - "reg-hasselt": { - "name": { - "nl": "Hasselt" - }, - "count": 1, - "children": { - "nis-71022": { - "name": { - "nl": "Hasselt" - }, - "count": 1, - "children": { - "nis-71022A": { - "name": { - "nl": "Hasselt" - }, - "count": 1 - } - } - } - } - } - } - }, - "nis-10000": { - "name": { - "nl": "Provincie Antwerpen", - "fr": "Province d'Anvers", - "de": "Provinz Antwerpen" - }, - "count": 1, - "children": { - "reg-kempen": { - "name": { - "nl": "Kempen" - }, - "count": 1, - "children": { - "nis-24062": { - "name": { - "nl": "Turnhout" - }, - "count": 1, - "children": { - "nis-24062A": { - "name": { - "nl": "Turnhout" - }, - "count": 1 - } - } - } - } - } - } - }, - "nis-20001": { - "name": { - "nl": "Provincie Vlaams-Brabant", - "fr": "Province du Brabant flamand", - "de": "Provinz Flämisch-Brabant" - }, - "count": 1, - "children": { - "reg-leuven": { - "name": { - "nl": "Leuven" - }, - "count": 1, - "children": { - "nis-24062": { - "name": { - "nl": "Leuven" - }, - "count": 1, - "children": { - "nis-24062A": { - "name": { - "nl": "Leuven" - }, - "count": 1 - } - } - } - } - } - } - }, - "nis-40000": { - "name": { - "nl": "Provincie Oost-Vlaanderen", - "fr": "Province de Flandre orientale", - "de": "Provinz Ostflandern" - }, - "count": 1, - "children": { - "reg-gent": { - "name": { - "nl": "Gent" - }, - "count": 1, - "children": { - "nis-44021": { - "name": { - "nl": "Gent" - }, - "count": 1, - "children": { - "nis-44021-Z": { - "name": { - "nl": "Gent" - }, - "count": 1 - } - } - } - } - } - } - } - } - } -} diff --git a/src/SearchClient.php b/src/SearchClient.php index bc50004c..89d19c2d 100644 --- a/src/SearchClient.php +++ b/src/SearchClient.php @@ -62,11 +62,6 @@ private function search(SearchQueryInterface $searchQuery, $type): PagedCollecti 'query' => $searchQuery->toArray(), ]; - // @todo: Remove when the organizers endpoint is functioning. - if ($type == 'organizers') { - return $this->serializer->deserialize(file_get_contents(__DIR__ . '/../data/organizers.json')); - } - $result = $this->client->request('GET', $type, $options); return $this->serializer->deserialize((string) $result->getBody()); } From abc0245497bd15908fedba34fa878bf8c5c13de8 Mon Sep 17 00:00:00 2001 From: Wouter Vanelslander Date: Tue, 29 Mar 2022 13:14:30 +0200 Subject: [PATCH 08/13] PUBLIQ-556: Organizer parsing fixes --- src/ValueObjects/GeoPoint.php | 12 ++++++------ src/ValueObjects/Organizer.php | 14 +++++++------- src/ValueObjects/TranslatedAddress.php | 18 ++++++++++++++++++ src/ValueObjects/TranslatedString.php | 9 +++++++++ 4 files changed, 40 insertions(+), 13 deletions(-) diff --git a/src/ValueObjects/GeoPoint.php b/src/ValueObjects/GeoPoint.php index 91132f39..007bcc62 100644 --- a/src/ValueObjects/GeoPoint.php +++ b/src/ValueObjects/GeoPoint.php @@ -9,18 +9,18 @@ final class GeoPoint { /** - * @var string|null - * @Type("string") + * @var float|null + * @Type("float") */ private $latitude; /** - * @var string|null - * @Type("string") + * @var float|null + * @Type("float") */ private $longitude; - public function getLatitude(): ?string + public function getLatitude(): ?float { return $this->latitude; } @@ -30,7 +30,7 @@ public function setLatitude(string $latitude): void $this->latitude = $latitude; } - public function getLongitude(): ?string + public function getLongitude(): ?float { return $this->longitude; } diff --git a/src/ValueObjects/Organizer.php b/src/ValueObjects/Organizer.php index 36940626..d42fc3a1 100644 --- a/src/ValueObjects/Organizer.php +++ b/src/ValueObjects/Organizer.php @@ -42,7 +42,7 @@ final class Organizer /** * @var \DateTime|null - * @Type("DateTime") + * @Type("DateTime<'Y-m-d\TH:i:sP'>") */ private $created; @@ -66,7 +66,7 @@ final class Organizer /** * @var \DateTime|null - * @Type("DateTime") + * @Type("DateTime<'Y-m-d\TH:i:sP'>") */ private $modified; @@ -104,7 +104,7 @@ final class Organizer * @var string|null * @Type("string") */ - private $image; + private $mainImage; /** * @var TranslatedAddress|null @@ -310,14 +310,14 @@ public function setRegions(array $regions): void $this->regions = $regions; } - public function getImage(): ?string + public function getMainImage(): ?string { - return $this->image; + return $this->mainImage; } - public function setImage(?string $image): void + public function setMainImage(?string $image): void { - $this->image = $image; + $this->mainImage = $image; } public function getDescription(): ?TranslatedString diff --git a/src/ValueObjects/TranslatedAddress.php b/src/ValueObjects/TranslatedAddress.php index c2b00a59..20604ff5 100644 --- a/src/ValueObjects/TranslatedAddress.php +++ b/src/ValueObjects/TranslatedAddress.php @@ -7,6 +7,8 @@ use JMS\Serializer\Annotation\HandlerCallback; use JMS\Serializer\DeserializationContext; use JMS\Serializer\JsonDeserializationVisitor; +use JMS\Serializer\JsonSerializationVisitor; +use JMS\Serializer\SerializationContext; final class TranslatedAddress { @@ -31,6 +33,15 @@ public function setAddresses(array $addresses): void $this->addresses = $addresses; } + /** + * @param string $langcode + * @param Address $address + */ + public function setAddress(string $langcode, Address $address): void + { + $this->addresses[$langcode] = $address; + } + public function getAddressForLanguage(string $langcode): ?Address { return $this->addresses[$langcode] ?? null; @@ -65,4 +76,11 @@ public function deserializeFromJson( ); } } + + /** + * @HandlerCallback("json", direction = "serialization") + */ + public function serializeFromObject(JsonSerializationVisitor $visitor, array $type = NULL, SerializationContext $context): array { + return $visitor->visitArray($this->addresses, [], $context); + } } diff --git a/src/ValueObjects/TranslatedString.php b/src/ValueObjects/TranslatedString.php index cbe85fec..bc32bc3c 100644 --- a/src/ValueObjects/TranslatedString.php +++ b/src/ValueObjects/TranslatedString.php @@ -7,6 +7,8 @@ use JMS\Serializer\Annotation\HandlerCallback; use JMS\Serializer\DeserializationContext; use JMS\Serializer\JsonDeserializationVisitor; +use JMS\Serializer\JsonSerializationVisitor; +use JMS\Serializer\SerializationContext; final class TranslatedString { @@ -51,4 +53,11 @@ public function deserializeFromJson( // Some properties are not translated yet in the api. Force them as nl. $this->values = is_array($value) ? $value : ['nl' => $value]; } + + /** + * @HandlerCallback("json", direction = "serialization") + */ + public function serializeFromObject(JsonSerializationVisitor $visitor, array $values = NULL, SerializationContext $context): array { + return $this->values ?? []; + } } From 439d53d19a85748f2cb3cad117062efe6de09c66 Mon Sep 17 00:00:00 2001 From: Wouter Vanelslander Date: Tue, 29 Mar 2022 17:45:16 +0200 Subject: [PATCH 09/13] PUBLIQ-556: Remove email property --- src/ValueObjects/Organizer.php | 16 ---------------- src/ValueObjects/TranslatedString.php | 8 +++++--- 2 files changed, 5 insertions(+), 19 deletions(-) diff --git a/src/ValueObjects/Organizer.php b/src/ValueObjects/Organizer.php index d42fc3a1..18a5ef74 100644 --- a/src/ValueObjects/Organizer.php +++ b/src/ValueObjects/Organizer.php @@ -76,12 +76,6 @@ final class Organizer */ private $labels = []; - /** - * @var array - * @Type("array") - */ - private $email; - /** * @var ContactPoint|null * @Type("CultuurNet\SearchV3\ValueObjects\ContactPoint") @@ -160,16 +154,6 @@ public function setName(TranslatedString $name): void $this->name = $name; } - public function getEmail(): array - { - return $this->email; - } - - public function setEmail(array $email): void - { - $this->email = $email; - } - public function getContactPoint(): ?ContactPoint { return $this->contactPoint; diff --git a/src/ValueObjects/TranslatedString.php b/src/ValueObjects/TranslatedString.php index bc32bc3c..1ddf7c8c 100644 --- a/src/ValueObjects/TranslatedString.php +++ b/src/ValueObjects/TranslatedString.php @@ -29,9 +29,11 @@ public function getValueForLanguage(string $langcode): string return $this->values[$langcode] ?? ''; } - /** - * @return string[] - */ + public function setValueForLanguage(string $langcode, string $value): void + { + $this->values[$langcode] = $value; + } + public function getValues(): array { return $this->values; From 2310fdc98d87105625bc2ec8349035e2fe8f2152 Mon Sep 17 00:00:00 2001 From: Wouter Vanelslander Date: Thu, 31 Mar 2022 13:22:07 +0200 Subject: [PATCH 10/13] PUBLIQ-556: Added uuid property to MediaObject --- src/ValueObjects/MediaObject.php | 40 ++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/src/ValueObjects/MediaObject.php b/src/ValueObjects/MediaObject.php index b6466d89..8becc121 100644 --- a/src/ValueObjects/MediaObject.php +++ b/src/ValueObjects/MediaObject.php @@ -16,6 +16,13 @@ final class MediaObject */ private $id; + /** + * @var string|null + * @Type("string") + * @SerializedName("id") + */ + private $uuid; + /** * @var string|null * @Type("string") @@ -40,6 +47,18 @@ final class MediaObject */ private $copyrightHolder; + /** + * @var string|null + * @Type("string") + */ + private $inLanguage; + + /** + * @var string|null + * @Type("string") + */ + private $language; + public function getId(): string { return $this->id; @@ -50,6 +69,16 @@ public function setId(string $id): void $this->id = $id; } + public function getUuid(): ?string + { + return $this->uuid; + } + + public function setUuid(?string $uuid): void + { + $this->uuid = $uuid; + } + public function getContentUrl(): ?string { return $this->contentUrl; @@ -89,4 +118,15 @@ public function setCopyrightHolder(string $copyrightHolder): void { $this->copyrightHolder = $copyrightHolder; } + + public function setLanguage(string $language): void + { + $this->language = $language; + $this->inLanguage = $language; + } + + public function getLanguage(): ?string + { + return $this->language ?? $this->inLanguage; + } } From 9ce5770d739fe51c16e8bb9e39d7252d7ee3cf1a Mon Sep 17 00:00:00 2001 From: Wouter Vanelslander Date: Thu, 31 Mar 2022 14:03:50 +0200 Subject: [PATCH 11/13] PUBLIQ-557: Nullable address properties --- src/ValueObjects/Address.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ValueObjects/Address.php b/src/ValueObjects/Address.php index 1a232a39..f1886e7f 100644 --- a/src/ValueObjects/Address.php +++ b/src/ValueObjects/Address.php @@ -38,7 +38,7 @@ public function __construct( $this->streetAddress = $streetAddress; } - public function getAddressCountry(): string + public function getAddressCountry(): ?string { return $this->addressCountry; } @@ -48,7 +48,7 @@ public function setAddressCountry(string $addressCountry): void $this->addressCountry = $addressCountry; } - public function getAddressLocality(): string + public function getAddressLocality(): ?string { return $this->addressLocality; } @@ -58,7 +58,7 @@ public function setAddressLocality(string $addressLocality): void $this->addressLocality = $addressLocality; } - public function getPostalCode(): string + public function getPostalCode(): ?string { return $this->postalCode; } @@ -68,7 +68,7 @@ public function setPostalCode(string $postalCode): void $this->postalCode = $postalCode; } - public function getStreetAddress(): string + public function getStreetAddress(): ?string { return $this->streetAddress; } From 5a4c0e574d61cafc3d7d28fa9e0f7c1aed1b91a1 Mon Sep 17 00:00:00 2001 From: Wouter Vanelslander Date: Mon, 11 Apr 2022 09:32:00 +0200 Subject: [PATCH 12/13] PUBLIQ-566: Added "addLabel" methods --- src/ValueObjects/Organizer.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/ValueObjects/Organizer.php b/src/ValueObjects/Organizer.php index 18a5ef74..89a89b2e 100644 --- a/src/ValueObjects/Organizer.php +++ b/src/ValueObjects/Organizer.php @@ -174,6 +174,11 @@ public function setHiddenLabels(array $hiddenLabels): void $this->hiddenLabels = $hiddenLabels; } + public function addHiddenLabel(string $hiddenLabel): void + { + $this->hiddenLabels[] = $hiddenLabel; + } + public function getAddress(): ?TranslatedAddress { return $this->address; @@ -284,6 +289,11 @@ public function setLabels(array $labels): void $this->labels = $labels; } + public function addLabel(string $label): void + { + $this->labels[] = $label; + } + public function getRegions(): array { return $this->regions; From 18dec2fe43f389ecc68521e2d1548ed82860d889 Mon Sep 17 00:00:00 2001 From: Wouter Vanelslander Date: Tue, 31 Jan 2023 17:15:36 +0100 Subject: [PATCH 13/13] PUBLIQ-774: Added attendanceMode helper methods --- src/ValueObjects/Event.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/ValueObjects/Event.php b/src/ValueObjects/Event.php index bccbee12..f28e88ad 100644 --- a/src/ValueObjects/Event.php +++ b/src/ValueObjects/Event.php @@ -112,4 +112,19 @@ public function setOnlineUrl(?string $onlineUrl): void { $this->onlineUrl = $onlineUrl; } + + public function isAttendanceModeOnline(): bool + { + return null !== $this->getAttendanceMode() && $this->getAttendanceMode() === 'online'; + } + + public function isAttendanceModeOffline(): bool + { + return null !== $this->getAttendanceMode() && $this->getAttendanceMode() === 'offline'; + } + + public function isAttendanceModeMixed(): bool + { + return null !== $this->getAttendanceMode() && $this->getAttendanceMode() === 'mixed'; + } }