Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TASK] Remove the configuration for the CSV file name #4185

Merged
merged 1 commit into from
Feb 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ This project adheres to [Semantic Versioning](https://semver.org/).

### Removed

- Improve some type annotations (#4014)
- Remove the configuration for the CSV file name (#4185)
- Drop the `strftime` date and time format configuration (#3990)
- Drop the unused `AbstractModel::addMissingProtocolToUrl()` (#3972)
- Drop `LegacyRegistration::commitToDatabase()` (#3971)
Expand Down Expand Up @@ -136,6 +136,7 @@ This project adheres to [Semantic Versioning](https://semver.org/).

### Fixed

- Improve some type annotations (#4014)
- Make some billing address fields longer (#4143)
- Improve display of users without a full name in the BE module (#4111)
- Avoid crashes for deleted lazy-loaded associations (#4109, #4115)
Expand Down
10 changes: 0 additions & 10 deletions Classes/Configuration/CsvExportConfigurationCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,13 @@ class CsvExportConfigurationCheck extends AbstractConfigurationCheck
{
protected function checkAllConfigurationValues(): void
{
$this->checkFilenameForRegistrationsCsv();
$this->checkFieldsFromFeUserForCsv();
$this->checkFieldsFromAttendanceForCsv();
$this->checkFieldsFromFeUserForEmailCsv();
$this->checkFieldsFromAttendanceForEmailCsv();
$this->checkShowAttendancesOnRegistrationQueueInEmailCsv();
}

private function checkFilenameForRegistrationsCsv(): void
{
$this->checkForNonEmptyString(
'filenameForRegistrationsCsv',
'This value specifies the file name to suggest for the CSV export of registration records.
If this value is not set, an empty filename will be used for saving the CSV file which will cause problems.'
);
}

private function checkFieldsFromFeUserForCsv(): void
{
$this->checkIfMultiInTableColumnsOrEmpty(
Expand Down
16 changes: 5 additions & 11 deletions Classes/Csv/CsvDownloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

namespace OliverKlee\Seminars\Csv;

use OliverKlee\Oelib\Configuration\ConfigurationRegistry;
use OliverKlee\Oelib\Interfaces\Configuration;
use OliverKlee\Seminars\Middleware\ResponseHeadersModifier;
use OliverKlee\Seminars\OldModel\LegacyEvent;
use TYPO3\CMS\Core\Utility\GeneralUtility;
Expand All @@ -17,12 +15,10 @@
*/
class CsvDownloader
{
protected Configuration $configuration;

public function __construct()
{
$this->configuration = ConfigurationRegistry::get('plugin.tx_seminars');
}
/**
* @var non-empty-string
*/
private const CSV_FILENAME = 'registrations.csv';

/**
* Creates a CSV export.
Expand Down Expand Up @@ -88,9 +84,7 @@ public function createListOfRegistrations(int $eventUid): string
*/
private function setContentTypeForRegistrationLists(): void
{
$filename = $this->configuration->getAsString('filenameForRegistrationsCsv');

$this->setPageTypeAndDisposition($filename);
$this->setPageTypeAndDisposition(self::CSV_FILENAME);
}

/**
Expand Down
8 changes: 6 additions & 2 deletions Classes/SchedulerTasks/MailNotifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@
*/
class MailNotifier extends AbstractTask
{
/**
* @var non-empty-string
*/
private const CSV_FILENAME = 'registrations.csv';

/**
* @var int<0, max>
*/
Expand Down Expand Up @@ -169,8 +174,7 @@ private function sendRemindersToOrganizers(LegacyEvent $event, string $messageKe
->text($this->customizeMessage($messageKey, $event, $organizer->getName()));
$emailBuilder->replyTo($replyTo);
if (\is_string($attachmentBody)) {
$fileName = $this->getConfiguration()->getAsString('filenameForRegistrationsCsv');
$emailBuilder->attach($attachmentBody, 'text/csv', $fileName);
$emailBuilder->attach($attachmentBody, 'text/csv', self::CSV_FILENAME);
}

$emailBuilder->build()->send();
Expand Down
3 changes: 0 additions & 3 deletions Configuration/TypoScript/PluginShared.typoscript
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,6 @@ plugin.tx_seminars {
# If there are at least this many vancancies, "enough" is displayed instead of the exact number.
showVacanciesThreshold = 10

# the filename proposed for CSV export of registration lists
filenameForRegistrationsCsv = registrations.csv

# comma-separated list of field names from fe_users that will be used for CSV export
fieldsFromFeUserForCsv = name,company,address,zip,city,country,telephone,email

Expand Down
13 changes: 5 additions & 8 deletions Documentation/Installation/SettingUpTheSchedulerTask/Index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ To setup the CLI, do the following:
reminder to the organizers. Setting zero will disable this reminder
about an event taking place.

- In order to customize the appended CSV, the options
*filenameForRegistrationsCsv* ”, “ *fieldsFromFeUserForEmailCsv* ”, “
*fieldsFromAttendanceForEmailCsv* and
*showAttendancesOnRegistrationQueueInEmailCsv* are relevant. Please
consider the corresponding section about CSV-File Attachmentfor more
- In order to customize the appended CSV, the options
*fieldsFromFeUserForEmailCsv*,
*fieldsFromAttendanceForEmailCsv* and
*showAttendancesOnRegistrationQueueInEmailCsv* are relevant. Please
consider the corresponding section about CSV-File attachment for more
details.

#. Add a seminars Scheduler task and provide UID of the page with the configuration.
Expand All @@ -50,9 +50,6 @@ CSV file use the following options:
contains the columns for the data from the registration records first
and then data from the corresponding FE user record.

- “ *filenameForRegistrationsCsv* ” determines the name of the attached
CSV file.

- “ *showAttendancesOnRegistrationQueueInEmailCsv* ” determines whether
registrations on the waiting list, should also be exported via CSV.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -477,21 +477,6 @@ only be configured using your TypoScript setup, but not via flexforms.
10


.. container:: table-row

Property
filenameForRegistrationsCsv

Data type
string

Description
the filename proposed for CSV export of registration lists

Default
registrations.csv


.. container:: table-row

Property
Expand Down
2 changes: 0 additions & 2 deletions Tests/Functional/Csv/CsvDownloaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ public function createAndOutputListOfRegistrationsForExistentEventSetsResponseHe

$this->configuration->setAsString('fieldsFromFeUserForCsv', 'name');
$this->configuration->setAsString('fieldsFromAttendanceForCsv', 'uid');
$this->configuration->setAsString('filenameForRegistrationsCsv', 'registrations.csv');

$this->subject->createAndOutputListOfRegistrations(1);

Expand All @@ -75,7 +74,6 @@ public function createAndOutputListOfRegistrationsForExistentEventSetsResponseHe

$this->configuration->setAsString('fieldsFromFeUserForCsv', 'name');
$this->configuration->setAsString('fieldsFromAttendanceForCsv', 'uid');
$this->configuration->setAsString('filenameForRegistrationsCsv', 'registrations.csv');

$this->subject->createAndOutputListOfRegistrations(1);

Expand Down
1 change: 0 additions & 1 deletion Tests/LegacyFunctional/SchedulerTasks/MailNotifierTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ protected function setUp(): void

$this->configuration->setAsInteger('sendEventTakesPlaceReminderDaysBeforeBeginDate', 2);
$this->configuration->setAsBoolean('sendCancelationDeadlineReminder', true);
$this->configuration->setAsString('filenameForRegistrationsCsv', 'registrations.csv');
$this->configuration->setAsString('fieldsFromAttendanceForEmailCsv', 'title');
$this->configuration->setAsBoolean('showAttendancesOnRegistrationQueueInEmailCsv', true);

Expand Down
5 changes: 0 additions & 5 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,6 @@ parameters:
count: 2
path: Classes/Csv/CsvDownloader.php

-
message: "#^Parameter \\#1 \\$csvFileName of method OliverKlee\\\\Seminars\\\\Csv\\\\CsvDownloader\\:\\:setPageTypeAndDisposition\\(\\) expects non\\-empty\\-string, string given\\.$#"
count: 1
path: Classes/Csv/CsvDownloader.php

-
message: "#^Call to function is_string\\(\\) with non\\-empty\\-string will always evaluate to true\\.$#"
count: 1
Expand Down