Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 217d14e6cc | |||
| 141ef8b1b3 | |||
| 4764857306 |
+1
-1
@@ -4,7 +4,7 @@
|
|||||||
"type": "contao-bundle",
|
"type": "contao-bundle",
|
||||||
"license": "proprietary",
|
"license": "proprietary",
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^8.4",
|
"php": "^8.3",
|
||||||
"contao/core-bundle": "^5.7",
|
"contao/core-bundle": "^5.7",
|
||||||
"contao/calendar-bundle": "^5.7",
|
"contao/calendar-bundle": "^5.7",
|
||||||
"contao/manager-plugin": "^2.0",
|
"contao/manager-plugin": "^2.0",
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ class ImportEventsCommand extends Command
|
|||||||
private const int TARGET_CALENDAR_ID = 1;
|
private const int TARGET_CALENDAR_ID = 1;
|
||||||
private const int TARGET_ORGANIZATION_ID = 142;
|
private const int TARGET_ORGANIZATION_ID = 142;
|
||||||
private const int TARGET_AUTHOR_ID = 8;
|
private const int TARGET_AUTHOR_ID = 8;
|
||||||
private const array DEFAULT_TAGS = [7, 8];
|
private const array DEFAULT_TAGS = [23];
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private readonly ContaoFramework $framework,
|
private readonly ContaoFramework $framework,
|
||||||
@@ -212,6 +212,7 @@ class ImportEventsCommand extends Command
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->syncOrganization($eventId);
|
$this->syncOrganization($eventId);
|
||||||
|
$this->syncTags($eventId, self::DEFAULT_TAGS);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function findEventIdByExternalId(string $externalId): int|null
|
private function findEventIdByExternalId(string $externalId): int|null
|
||||||
@@ -240,6 +241,33 @@ class ImportEventsCommand extends Command
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int[] $tagIds
|
||||||
|
*/
|
||||||
|
private function syncTags(int $eventId, array $tagIds): void
|
||||||
|
{
|
||||||
|
$normalizedTagIds = array_values(array_unique(array_map('intval', $tagIds)));
|
||||||
|
|
||||||
|
$this->connection->delete('tl_tags_rel', [
|
||||||
|
'pid' => $eventId,
|
||||||
|
'ptable' => 'tl_calendar_events',
|
||||||
|
'field' => 'tags',
|
||||||
|
]);
|
||||||
|
|
||||||
|
foreach ($normalizedTagIds as $tagId) {
|
||||||
|
if ($tagId <= 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->connection->insert('tl_tags_rel', [
|
||||||
|
'tag_id' => $tagId,
|
||||||
|
'pid' => $eventId,
|
||||||
|
'ptable' => 'tl_calendar_events',
|
||||||
|
'field' => 'tags',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private function generateAlias(string $title, int $startDate, string $preferredAlias, int|null $eventId): string
|
private function generateAlias(string $title, int $startDate, string $preferredAlias, int|null $eventId): string
|
||||||
{
|
{
|
||||||
$candidate = $preferredAlias !== '' ? $this->normalizeAlias($preferredAlias) : '';
|
$candidate = $preferredAlias !== '' ? $this->normalizeAlias($preferredAlias) : '';
|
||||||
|
|||||||
Reference in New Issue
Block a user