Skip to content

Commit 8920364

Browse files
committed
[FEATURE] Add Event.downloadsForAttendees
1 parent d3a017c commit 8920364

File tree

10 files changed

+137
-0
lines changed

10 files changed

+137
-0
lines changed

CHANGELOG.md

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

88
### Added
99

10+
- Add `Event.downloadsForAttendees` (#4243)
1011
- Add unregistration to the `my registrations` single view (#4236)
1112
- Add a reimplemented "my registrations" plugin
1213
(#4207, #4209, #4210, #4214, #4217, #4219, #4225, #4226, #4228)

Classes/Domain/Model/Event/EventDateInterface.php

+6
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use OliverKlee\Seminars\Domain\Model\RegistrationCheckbox;
1212
use OliverKlee\Seminars\Domain\Model\Speaker;
1313
use OliverKlee\Seminars\Domain\Model\Venue;
14+
use TYPO3\CMS\Extbase\Domain\Model\FileReference;
1415
use TYPO3\CMS\Extbase\Persistence\ObjectStorage;
1516

1617
/**
@@ -169,4 +170,9 @@ public function hasUsableWebinarUrl(): bool;
169170
public function getAdditionalEmailText(): string;
170171

171172
public function getRoom(): string;
173+
174+
/**
175+
* @return ObjectStorage<FileReference>
176+
*/
177+
public function getDownloadsForAttendees(): ObjectStorage;
172178
}

Classes/Domain/Model/Event/EventDateTrait.php

+24
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use TYPO3\CMS\Extbase\Annotation\ORM\Lazy;
1616
use TYPO3\CMS\Extbase\Annotation\ORM\Transient;
1717
use TYPO3\CMS\Extbase\Annotation\Validate;
18+
use TYPO3\CMS\Extbase\Domain\Model\FileReference;
1819
use TYPO3\CMS\Extbase\Persistence\ObjectStorage;
1920

2021
/**
@@ -144,6 +145,12 @@ trait EventDateTrait
144145
EventDateInterface::EVENT_FORMAT_ONLINE,
145146
];
146147

148+
/**
149+
* @var ObjectStorage<FileReference>
150+
* @Lazy
151+
*/
152+
protected ObjectStorage $downloadsForAttendees;
153+
147154
private function initializeEventDate(): void
148155
{
149156
$this->venues = new ObjectStorage();
@@ -152,6 +159,7 @@ private function initializeEventDate(): void
152159
$this->accommodationOptions = new ObjectStorage();
153160
$this->foodOptions = new ObjectStorage();
154161
$this->registrationCheckboxes = new ObjectStorage();
162+
$this->downloadsForAttendees = new ObjectStorage();
155163
}
156164

157165
public function getStart(): ?\DateTime
@@ -589,4 +597,20 @@ public function setRoom(string $room): void
589597
{
590598
$this->room = $room;
591599
}
600+
601+
/**
602+
* @return ObjectStorage<FileReference>
603+
*/
604+
public function getDownloadsForAttendees(): ObjectStorage
605+
{
606+
return $this->downloadsForAttendees;
607+
}
608+
609+
/**
610+
* @param ObjectStorage<FileReference> $files
611+
*/
612+
public function setDownloadsForAttendees(ObjectStorage $files): void
613+
{
614+
$this->downloadsForAttendees = $files;
615+
}
592616
}

Configuration/Extbase/Persistence/Classes.php

+2
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
'accommodationOptions' => ['fieldName' => 'lodgings'],
6767
'foodOptions' => ['fieldName' => 'foods'],
6868
'registrationCheckboxes' => ['fieldName' => 'checkboxes'],
69+
'downloadsForAttendees' => ['fieldName' => 'attached_files'],
6970
],
7071
],
7172
EventTopic::class => [
@@ -104,6 +105,7 @@
104105
'accommodationOptions' => ['fieldName' => 'lodgings'],
105106
'foodOptions' => ['fieldName' => 'foods'],
106107
'registrationCheckboxes' => ['fieldName' => 'checkboxes'],
108+
'downloadsForAttendees' => ['fieldName' => 'attached_files'],
107109
],
108110
],
109111
EventType::class => [

Tests/Functional/Domain/Repository/Event/EventRepositoryTest.php

+31
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
use OliverKlee\Seminars\Domain\Repository\AbstractRawDataCapableRepository;
2222
use OliverKlee\Seminars\Domain\Repository\Event\EventRepository;
2323
use OliverKlee\Seminars\Tests\Support\BackEndTestsTrait;
24+
use TYPO3\CMS\Extbase\Domain\Model\FileReference;
2425
use TYPO3\CMS\Extbase\Persistence\Repository;
2526
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
2627

@@ -614,6 +615,36 @@ public function mapsPaymentMethodsAssociationForEventTopic(): void
614615
self::assertInstanceOf(PaymentMethod::class, $associatedModels->toArray()[0]);
615616
}
616617

618+
/**
619+
* @test
620+
*/
621+
public function mapsDownloadsForAttendeesAssociationForSingleEvent(): void
622+
{
623+
$this->importCSVDataSet(__DIR__ . '/Fixtures/propertyMapping/SingleEventWithOneDownloadForAttendees.csv');
624+
625+
$result = $this->subject->findByUid(1);
626+
self::assertInstanceOf(SingleEvent::class, $result);
627+
628+
$associatedModels = $result->getDownloadsForAttendees();
629+
self::assertCount(1, $associatedModels);
630+
self::assertInstanceOf(FileReference::class, $associatedModels->toArray()[0]);
631+
}
632+
633+
/**
634+
* @test
635+
*/
636+
public function mapsDownloadsForAttendeesAssociationForEventDate(): void
637+
{
638+
$this->importCSVDataSet(__DIR__ . '/Fixtures/propertyMapping/EventDateWithOneDownloadForAttendees.csv');
639+
640+
$result = $this->subject->findByUid(1);
641+
self::assertInstanceOf(EventDate::class, $result);
642+
643+
$associatedModels = $result->getDownloadsForAttendees();
644+
self::assertCount(1, $associatedModels);
645+
self::assertInstanceOf(FileReference::class, $associatedModels->toArray()[0]);
646+
}
647+
617648
/**
618649
* @test
619650
*/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
"tx_seminars_seminars"
2+
,"uid","object_type","topic","title","attached_files"
3+
,1,2,2,"Event Date with one download for attendees",1
4+
,2,1,0,"Topic",0
5+
6+
"sys_file_reference"
7+
,"uid","uid_foreign","tablenames","fieldname"
8+
,1,1,"tx_seminars_seminars","attached_files"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
"tx_seminars_seminars"
2+
,"uid","object_type","title","attached_files"
3+
,1,0,"Event with one download for attendees",1
4+
5+
"sys_file_reference"
6+
,"uid","uid_foreign","tablenames","fieldname"
7+
,1,1,"tx_seminars_seminars","attached_files"

Tests/Unit/Domain/Model/Event/EventDateTest.php

+24
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
use TYPO3\CMS\Core\Context\Context;
2424
use TYPO3\CMS\Core\Context\DateTimeAspect;
2525
use TYPO3\CMS\Core\Utility\GeneralUtility;
26+
use TYPO3\CMS\Extbase\Domain\Model\FileReference;
2627
use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;
2728
use TYPO3\CMS\Extbase\Persistence\ObjectStorage;
2829
use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
@@ -1652,4 +1653,27 @@ public function areDownloadsPossibleByDateForDownloadStartInFutureReturnsFalse()
16521653

16531654
self::assertFalse($this->subject->areDownloadsPossibleByDate());
16541655
}
1656+
1657+
/**
1658+
* @test
1659+
*/
1660+
public function getDownloadsForAttendeesInitiallyReturnsEmptyStorage(): void
1661+
{
1662+
$venues = $this->subject->getDownloadsForAttendees();
1663+
1664+
self::assertInstanceOf(ObjectStorage::class, $venues);
1665+
self::assertCount(0, $venues);
1666+
}
1667+
1668+
/**
1669+
* @test
1670+
*/
1671+
public function setDownloadsForAttendeesSetsDownloadsForAttendees(): void
1672+
{
1673+
/** @var ObjectStorage<FileReference> $files */
1674+
$files = new ObjectStorage();
1675+
$this->subject->setDownloadsForAttendees($files);
1676+
1677+
self::assertSame($files, $this->subject->getDownloadsForAttendees());
1678+
}
16551679
}

Tests/Unit/Domain/Model/Event/SingleEventTest.php

+24
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
use TYPO3\CMS\Core\Context\Context;
2424
use TYPO3\CMS\Core\Context\DateTimeAspect;
2525
use TYPO3\CMS\Core\Utility\GeneralUtility;
26+
use TYPO3\CMS\Extbase\Domain\Model\FileReference;
2627
use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;
2728
use TYPO3\CMS\Extbase\Persistence\ObjectStorage;
2829
use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
@@ -1773,4 +1774,27 @@ public function areDownloadsPossibleByDateForDownloadStartInFutureReturnsFalse()
17731774

17741775
self::assertFalse($this->subject->areDownloadsPossibleByDate());
17751776
}
1777+
1778+
/**
1779+
* @test
1780+
*/
1781+
public function getDownloadsForAttendeesInitiallyReturnsEmptyStorage(): void
1782+
{
1783+
$venues = $this->subject->getDownloadsForAttendees();
1784+
1785+
self::assertInstanceOf(ObjectStorage::class, $venues);
1786+
self::assertCount(0, $venues);
1787+
}
1788+
1789+
/**
1790+
* @test
1791+
*/
1792+
public function setDownloadsForAttendeesSetsDownloadsForAttendees(): void
1793+
{
1794+
/** @var ObjectStorage<FileReference> $files */
1795+
$files = new ObjectStorage();
1796+
$this->subject->setDownloadsForAttendees($files);
1797+
1798+
self::assertSame($files, $this->subject->getDownloadsForAttendees());
1799+
}
17761800
}

phpstan-baseline.neon

+10
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,11 @@ parameters:
230230
count: 1
231231
path: Classes/Domain/Model/Event/EventDate.php
232232

233+
-
234+
message: "#^Parameters should have \"TYPO3\\\\CMS\\\\Extbase\\\\Persistence\\\\ObjectStorage\\<TYPO3\\\\CMS\\\\Extbase\\\\Domain\\\\Model\\\\FileReference\\>\" types as the only types passed to this method$#"
235+
count: 1
236+
path: Classes/Domain/Model/Event/EventDate.php
237+
233238
-
234239
message: "#^Method OliverKlee\\\\Seminars\\\\Domain\\\\Model\\\\Event\\\\EventTopic\\:\\:getEventType\\(\\) should return OliverKlee\\\\Seminars\\\\Domain\\\\Model\\\\EventType\\|null but returns object\\|null\\.$#"
235240
count: 1
@@ -280,6 +285,11 @@ parameters:
280285
count: 1
281286
path: Classes/Domain/Model/Event/SingleEvent.php
282287

288+
-
289+
message: "#^Parameters should have \"TYPO3\\\\CMS\\\\Extbase\\\\Persistence\\\\ObjectStorage\\<TYPO3\\\\CMS\\\\Extbase\\\\Domain\\\\Model\\\\FileReference\\>\" types as the only types passed to this method$#"
290+
count: 1
291+
path: Classes/Domain/Model/Event/SingleEvent.php
292+
283293
-
284294
message: "#^Call to static method OliverKlee\\\\Seminars\\\\Domain\\\\Model\\\\Price\\:\\:isPriceCodeValid\\(\\) with 'price_regular'\\|'price_regular_early'\\|'price_special'\\|'price_special_early' will always evaluate to true\\.$#"
285295
count: 1

0 commit comments

Comments
 (0)