Skip to content

Commit 69d0d02

Browse files
authored
[TASK] Drop Venue.country (#4273)
Part of #3923
1 parent d3d9041 commit 69d0d02

File tree

12 files changed

+6
-634
lines changed

12 files changed

+6
-634
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ This project adheres to [Semantic Versioning](https://semver.org/).
110110

111111
### Removed
112112

113+
- Drop `Venue.country` (#4273)
113114
- Drop `Event.language` (#4271)
114115
- Drop the event language from the FE list and single view (#4270)
115116
- Drop the country column from the FE list views (#4269)

Classes/BackEnd/TceForms.php

-50
This file was deleted.

Classes/Model/Place.php

-25
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,7 @@
44

55
namespace OliverKlee\Seminars\Model;
66

7-
use OliverKlee\Oelib\Exception\NotFoundException;
8-
use OliverKlee\Oelib\Mapper\CountryMapper;
9-
use OliverKlee\Oelib\Mapper\MapperRegistry;
107
use OliverKlee\Oelib\Model\AbstractModel;
11-
use OliverKlee\Oelib\Model\Country;
128

139
/**
1410
* This class represents a place.
@@ -43,25 +39,4 @@ public function getCity(): string
4339
{
4440
return $this->getAsString('city');
4541
}
46-
47-
public function getCountry(): ?Country
48-
{
49-
$countryCode = $this->getAsString('country');
50-
if ($countryCode === '') {
51-
return null;
52-
}
53-
54-
try {
55-
$country = MapperRegistry::get(CountryMapper::class)->findByIsoAlpha2Code($countryCode);
56-
} catch (NotFoundException $exception) {
57-
$country = null;
58-
}
59-
60-
return $country;
61-
}
62-
63-
public function hasCountry(): bool
64-
{
65-
return $this->getCountry() !== null;
66-
}
6742
}

Classes/OldModel/LegacyEvent.php

+2-96
Original file line numberDiff line numberDiff line change
@@ -263,75 +263,6 @@ public function getPlaceWithDetails(TemplateHelper $plugin): string
263263
return $plugin->getSubpart('PLACE_LIST_COMPLETE');
264264
}
265265

266-
/**
267-
* Checks whether the current event has at least one place set, and if
268-
* this/these pace(s) have a country set.
269-
* Returns a boolean TRUE if at least one of the set places has a
270-
* country set, returns FALSE otherwise.
271-
*
272-
* IMPORTANT: This function does not check whether the saved ISO code is
273-
* valid at all. As this field is filled through the BE from a prefilled
274-
* list, this should never be an issue at all.
275-
*
276-
* @return bool whether at least one place with country are set for the current event
277-
*/
278-
public function hasCountry(): bool
279-
{
280-
$placesWithCountry = $this->getPlacesWithCountry();
281-
282-
return $this->hasPlace() && !empty($placesWithCountry);
283-
}
284-
285-
/**
286-
* Returns an array of two-char ISO codes of countries for this event.
287-
* These are fetched from the referenced place records of this event. If no
288-
* place is set, or the set place(s) don't have any country set, an empty
289-
* array will be returned.
290-
*
291-
* @return list<string> the list of ISO codes for the countries of this event, may be empty
292-
*/
293-
public function getPlacesWithCountry(): array
294-
{
295-
if (!$this->hasPlace()) {
296-
return [];
297-
}
298-
299-
$countries = array_column($this->getPlacesAsArray(), 'country');
300-
return array_filter(
301-
$countries,
302-
static fn (string $country): bool => $country !== ''
303-
);
304-
}
305-
306-
/**
307-
* Returns a comma-separated list of country names that were set in the
308-
* place record(s).
309-
* If no places are set, or no countries are selected in the set places,
310-
* an empty string will be returned.
311-
*
312-
* @return string comma-separated list of countries for this event, may be empty
313-
*/
314-
public function getCountry(): string
315-
{
316-
if (!$this->hasCountry()) {
317-
return '';
318-
}
319-
320-
$countryList = [];
321-
322-
// Fetches the countries from the corresponding place records, may be
323-
// an empty array.
324-
// Get the real country names from the ISO codes.
325-
foreach ($this->getPlacesWithCountry() as $currentCountry) {
326-
$countryList[] = $this->getCountryNameFromIsoCode($currentCountry);
327-
}
328-
329-
// Makes sure that each country is exactly once in the array and then
330-
// returns this list.
331-
$countryListUnique = array_unique($countryList);
332-
return implode(', ', $countryListUnique);
333-
}
334-
335266
/**
336267
* Returns a comma-separated list of city names that were set in the place
337268
* record(s).
@@ -381,25 +312,6 @@ public function getCitiesFromPlaces(): array
381312
return \array_column($this->getPlacesAsArray(), 'city');
382313
}
383314

384-
/**
385-
* Returns the name of the requested country from the static info tables.
386-
* If the country with this ISO code could not be found in the database,
387-
* an empty string is returned instead.
388-
*
389-
* @param string $isoCode the ISO 3166-1 alpha-2 code of the country, must not be empty
390-
*
391-
* @return string the short local name of the country or an empty
392-
* string if the country could not be found
393-
*/
394-
public function getCountryNameFromIsoCode(string $isoCode): string
395-
{
396-
$table = 'static_countries';
397-
$title = self::getConnectionForTable($table)
398-
->select(['cn_short_local'], $table, ['cn_iso_2' => $isoCode])->fetchOne();
399-
400-
return \is_string($title) ? $title : '';
401-
}
402-
403315
/**
404316
* Gets our place (or places) with address and links as HTML, not RTE'ed yet,
405317
* separated by LF.
@@ -432,12 +344,6 @@ protected function getPlaceWithDetailsRaw(): string
432344
$place['zip'] . ' ' . $place['city']
433345
);
434346
}
435-
if ((string)($place['country'] ?? '') !== '') {
436-
$countryName = $this->getCountryNameFromIsoCode($place['country']);
437-
if ($countryName !== '') {
438-
$descriptionParts[] = $countryName;
439-
}
440-
}
441347

442348
if (!empty($descriptionParts)) {
443349
$placeText .= ', ' . implode(', ', $descriptionParts);
@@ -457,7 +363,7 @@ protected function getPlaceWithDetailsRaw(): string
457363
*
458364
* The array will be two-dimensional: The first dimensional is just numeric.
459365
* The second dimension is associative with the following keys:
460-
* title, address, city, country, homepage, directions
366+
* title, address, city, homepage, directions
461367
*
462368
* @return list<array<string, string|int>>
463369
* all places as a two-dimensional array, will be empty if there are no places assigned
@@ -467,7 +373,7 @@ protected function getPlacesAsArray(): array
467373
$queryBuilder = self::getQueryBuilderForTable('tx_seminars_sites');
468374

469375
return $queryBuilder
470-
->select('uid', 'title', 'address', 'zip', 'city', 'country', 'homepage', 'directions')
376+
->select('uid', 'title', 'address', 'zip', 'city', 'homepage', 'directions')
471377
->from('tx_seminars_sites')
472378
->leftJoin(
473379
'tx_seminars_sites',

Configuration/TCA/tx_seminars_sites.php

+1-16
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<?php
22

3-
use OliverKlee\Seminars\BackEnd\TceForms;
4-
53
defined('TYPO3') or die();
64

75
$tca = [
@@ -53,19 +51,6 @@
5351
'eval' => 'required,trim',
5452
],
5553
],
56-
'country' => [
57-
'exclude' => 1,
58-
'label' => 'LLL:EXT:seminars/Resources/Private/Language/locallang_db.xlf:tx_seminars_sites.country',
59-
'config' => [
60-
'type' => 'select',
61-
'renderType' => 'selectSingle',
62-
'items' => [['', '0']],
63-
'itemsProcFunc' => TceForms::class . '->createCountrySelector',
64-
'size' => 1,
65-
'minitems' => 0,
66-
'maxitems' => 1,
67-
],
68-
],
6954
'homepage' => [
7055
'exclude' => 1,
7156
'label' => 'LLL:EXT:seminars/Resources/Private/Language/locallang_db.xlf:tx_seminars_sites.homepage',
@@ -128,7 +113,7 @@
128113
],
129114
'types' => [
130115
'0' => [
131-
'showitem' => 'title, address, zip, city, country, homepage, directions, '
116+
'showitem' => 'title, address, zip, city, homepage, directions, '
132117
. 'contact_person, email_address, phone_number, notes',
133118
],
134119
],

Resources/Private/Language/locallang_db.xlf

-3
Original file line numberDiff line numberDiff line change
@@ -516,9 +516,6 @@
516516
<trans-unit id="tx_seminars_sites.city">
517517
<source>City</source>
518518
</trans-unit>
519-
<trans-unit id="tx_seminars_sites.country">
520-
<source>Country</source>
521-
</trans-unit>
522519
<trans-unit id="tx_seminars_sites.homepage">
523520
<source>Homepage</source>
524521
</trans-unit>

Tests/Functional/OldModel/Fixtures/Events/Countries.xml

-23
This file was deleted.

Tests/Functional/OldModel/Fixtures/Events/EventsWithPlaces.xml

-21
Original file line numberDiff line numberDiff line change
@@ -87,27 +87,6 @@
8787
<directions>3 turns left, then always right</directions>
8888
<homepage>www.example.com</homepage>
8989
</tx_seminars_sites>
90-
<tx_seminars_sites>
91-
<uid>2</uid>
92-
<title>with valid country</title>
93-
<country>ch</country>
94-
</tx_seminars_sites>
95-
<tx_seminars_sites>
96-
<uid>3</uid>
97-
<title>with invalid country</title>
98-
<country>xy</country>
99-
</tx_seminars_sites>
100-
<tx_seminars_sites>
101-
<uid>4</uid>
102-
<title>with deleted country</title>
103-
<deleted>1</deleted>
104-
<country>de</country>
105-
</tx_seminars_sites>
106-
<tx_seminars_sites>
107-
<uid>5</uid>
108-
<title>with another valid country</title>
109-
<country>de</country>
110-
</tx_seminars_sites>
11190
<tx_seminars_sites>
11291
<uid>6</uid>
11392
<title>The garden (without country)</title>

0 commit comments

Comments
 (0)