Skip to content

Commit

Permalink
Add source while importing from Destination Data One
Browse files Browse the repository at this point in the history
Destination Data One provides an source info explaining where the data
originally came from.
This is now added to event records and exposed in TYPO3 backend.
That allows editors to check the source and contact corresponding
sources in order to fix broken data.

Relates: #10630
  • Loading branch information
DanielSiepmann committed Aug 10, 2023
1 parent 3d0d5d8 commit d92d5fb
Show file tree
Hide file tree
Showing 10 changed files with 362 additions and 10 deletions.
20 changes: 20 additions & 0 deletions Classes/Domain/Model/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,16 @@ class Event extends AbstractEntity
*/
protected $dataProcessing;

/**
* @var string
*/
protected $sourceName = '';

/**
* @var string
*/
protected $sourceUrl = '';

public function __construct()
{
$this->initStorageObjects();
Expand Down Expand Up @@ -469,4 +479,14 @@ public function getLocalizedUid(): int
{
return $this->_localizedUid;
}

public function setSourceName(string $name): void
{
$this->sourceName = $name;
}

public function setSourceUrl(string $url): void
{
$this->sourceUrl = $url;
}
}
15 changes: 15 additions & 0 deletions Classes/Service/DestinationDataImportService.php
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,10 @@ public function processData(array $data): int
$this->setAssets($event['media_objects']);
}

if ($event['source'] ?? false) {
$this->setSource($event['source']);
}

$this->eventDispatcher->dispatch(new EventImportEvent(
$existingEvent,
$this->tmpCurrentEvent
Expand Down Expand Up @@ -488,6 +492,17 @@ private function setAssets(array $assets): void
$this->tmpCurrentEvent->setImages($images);
}

private function setSource(array $source): void
{
if (isset($source['value'])) {
$this->tmpCurrentEvent->setSourceName($source['value']);
}

if (isset($source['url'])) {
$this->tmpCurrentEvent->setSourceUrl($source['url']);
}
}

/**
* Fetch the boolean value for requested attribute.
*
Expand Down
28 changes: 26 additions & 2 deletions Configuration/TCA/tx_events_domain_model_event.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
],
'types' => [
'1' => [
'showitem' => '--palette--;' . $l10nPathFE . ':palette.general;general,
'showitem' => '
sys_language_uid,
l10n_parent,
l10n_diffsource,
Expand All @@ -40,6 +40,7 @@
slug,
ticket,
global_id,
--palette--;;source,
--div--;' . $l10nPath . ':tx_events_domain_model_event.tabs.text,
details,
price_info,
Expand Down Expand Up @@ -67,7 +68,12 @@
endtime',
],
],

'palettes' => [
'source' => [
'label' => $l10nPath . ':tx_events_domain_model_event.palette.source',
'showitem' => 'source_name, source_url',
],
],
'columns' => [
'sys_language_uid' => [
'exclude' => true,
Expand Down Expand Up @@ -187,6 +193,24 @@
'eval' => 'trim',
],
],
'source_name' => [
'exclude' => true,
'label' => $l10nPath . ':tx_events_domain_model_event.source_name',
'config' => [
'type' => 'input',
'readOnly' => true,
],
],
'source_url' => [
'exclude' => true,
'label' => $l10nPath . ':tx_events_domain_model_event.source_url',
'config' => [
'type' => 'input',
'renderType' => 'inputLink',
'softref' => 'typolink',
'readOnly' => true,
],
],
'slug' => [
'exclude' => true,
'label' => $l10nPath . ':tx_events_domain_model_event.slug',
Expand Down
5 changes: 5 additions & 0 deletions Documentation/Changelog/3.5.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ Features

* Allow to modify an event object before importing.

* Add source to events.
Destination Data One provides the original source, either them self or an external.
This is now saved in order to make it easier for editors and companies to contact
the original source and ask to fix broken data.

Fixes
-----

Expand Down
12 changes: 12 additions & 0 deletions Resources/Private/Language/de.locallang_csh_event.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@
<source>Social Media</source>
<target>Social Media</target>
</trans-unit>
<trans-unit id="tx_events_domain_model_event.palette.source">
<source>Source</source>
<target>Quelle</target>
</trans-unit>
<trans-unit id="tx_events_domain_model_event">
<source>Event</source>
<target>Veranstaltung</target>
Expand All @@ -51,6 +55,14 @@
<source>Global UID</source>
<target>Globale UID</target>
</trans-unit>
<trans-unit id="tx_events_domain_model_event.source_name">
<source>Source Name</source>
<target>Name der Quelle</target>
</trans-unit>
<trans-unit id="tx_events_domain_model_event.source_url">
<source>Source URL</source>
<target>URL der Quelle</target>
</trans-unit>
<trans-unit id="tx_events_domain_model_event.slug">
<source>Slug</source>
<target>URL-Segment</target>
Expand Down
9 changes: 9 additions & 0 deletions Resources/Private/Language/locallang_csh_event.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
<trans-unit id="tx_events_domain_model_event.tabs.social">
<source>Social Media</source>
</trans-unit>
<trans-unit id="tx_events_domain_model_event.palette.source">
<source>Source</source>
</trans-unit>
<trans-unit id="tx_events_domain_model_event.title">
<source>Title</source>
</trans-unit>
Expand All @@ -39,6 +42,12 @@
<trans-unit id="tx_events_domain_model_event.global_id">
<source>Global UID</source>
</trans-unit>
<trans-unit id="tx_events_domain_model_event.source_name">
<source>Source Name</source>
</trans-unit>
<trans-unit id="tx_events_domain_model_event.source_url">
<source>Source URL</source>
</trans-unit>
<trans-unit id="tx_events_domain_model_event.slug">
<source>Slug</source>
</trans-unit>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

return [
'tx_events_domain_model_event' => [
[
'uid' => 1,
'global_id' => 'e_100347853',
'source_name' => 'destination.one',
'source_url' => 'http://destination.one/',
],
[
'uid' => 2,
'global_id' => 'e_100347854',
'source_name' => 'Foreign Example 1',
'source_url' => 'https://example.com',
],
[
'uid' => 3,
'global_id' => 'e_100347855',
'source_name' => 'Foreign Example 2',
'source_url' => 'https://example.com/something-else',
],
],
];
Loading

0 comments on commit d92d5fb

Please sign in to comment.