Refactor type handling to contao-tags and add module tag filters
This commit is contained in:
@@ -73,7 +73,7 @@ class EventEditController extends AbstractFrontendModuleController
|
||||
'startTime' => null,
|
||||
'endTime' => null,
|
||||
'location_id' => 0,
|
||||
'type' => null,
|
||||
'tags' => null,
|
||||
'teaser' => '',
|
||||
'description' => '',
|
||||
'url' => '',
|
||||
@@ -88,9 +88,11 @@ class EventEditController extends AbstractFrontendModuleController
|
||||
}
|
||||
|
||||
$memberOrganizationIds = $this->eventRepository->getOrganizationIdsForMember((int) $user->id);
|
||||
$allowedEventTagIds = array_values(array_unique(array_map('intval', StringUtil::deserialize($model->eventTypeTags ?? null, true))));
|
||||
$organizationChoices = $this->eventRepository->getOrganizationChoicesForMember((int) $user->id);
|
||||
$showOrganization = count($memberOrganizationIds) > 1;
|
||||
$currentOrganizationIds = $this->eventRepository->getOrganizationIdsForEvent($eventId);
|
||||
$currentTagIds = $this->eventRepository->getTagIdsForEvent($eventId);
|
||||
|
||||
$formData = [
|
||||
'title' => (string) ($event['title'] ?? ''),
|
||||
@@ -100,7 +102,7 @@ class EventEditController extends AbstractFrontendModuleController
|
||||
'startTime' => ('1' === (string) ($event['addTime'] ?? '') && !empty($event['startTime'])) ? date('H:i', (int) $event['startTime']) : '',
|
||||
'endTime' => $this->resolveFormEndTime($event),
|
||||
'location_id' => (int) ($event['location_id'] ?? 0),
|
||||
'type' => StringUtil::deserialize($event['type'] ?? null, true),
|
||||
'tags' => $currentTagIds,
|
||||
'teaser' => (string) ($event['teaser'] ?? ''),
|
||||
'description' => (string) ($event['description'] ?? ''),
|
||||
'url' => (string) ($event['url'] ?? ''),
|
||||
@@ -135,6 +137,7 @@ class EventEditController extends AbstractFrontendModuleController
|
||||
|
||||
$form = $this->createForm(EventType::class, $formData, [
|
||||
'location_choices' => $this->eventRepository->getLocationChoices(),
|
||||
'tag_choices' => $this->eventRepository->getTagChoicesForEventType($allowedEventTagIds),
|
||||
'organization_choices' => $organizationChoices,
|
||||
'selected_organization_ids' => $showOrganization ? ($formData['organization_ids'] ?? []) : [],
|
||||
'show_organization' => $showOrganization,
|
||||
@@ -213,6 +216,14 @@ class EventEditController extends AbstractFrontendModuleController
|
||||
$this->eventRepository->update($eventId, $submittedData);
|
||||
}
|
||||
|
||||
$selectedTagIds = array_values(array_unique(array_map('intval', (array) ($submittedData['tags'] ?? []))));
|
||||
|
||||
if ([] !== $allowedEventTagIds) {
|
||||
$selectedTagIds = array_values(array_intersect($selectedTagIds, $allowedEventTagIds));
|
||||
}
|
||||
|
||||
$this->eventRepository->assignTagsToEvent($eventId, $selectedTagIds);
|
||||
|
||||
$useImage = !empty($submittedData['addImage']);
|
||||
$removeImage = '1' === (string) $request->request->get('remove_image', '0');
|
||||
$uploadedImage = $form->get('eventUpload')->getData();
|
||||
|
||||
Reference in New Issue
Block a user