Skip to content

Commit 1dbcfe6

Browse files
authored
Feature video validate event (#38)
* Set default limit for video validation to 0. * Add ModifyVideoValidateEvent for custom validation actions Introduced a new `ModifyVideoValidateEvent` to enable custom actions during video validation. Updated `VideoService` to dispatch this event and added documentation to guide developers on registering and handling the event. * Remove change from other pull request * Rename event class in README.md --------- Co-authored-by: Kevin Meckl <kevin.meckl@zdrei.com>
1 parent 7349572 commit 1dbcfe6

3 files changed

Lines changed: 72 additions & 1 deletion

File tree

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Ayacoo\VideoValidator\Event;
6+
7+
use TYPO3\CMS\Core\Resource\FileInterface;
8+
9+
final class ModifyVideoValidateEvent
10+
{
11+
public function __construct(
12+
private readonly ?FileInterface $file,
13+
private readonly array $properties = [],
14+
) {
15+
}
16+
17+
public function getFile(): ?FileInterface
18+
{
19+
return $this->file;
20+
}
21+
22+
public function getProperties(): array
23+
{
24+
return $this->properties;
25+
}
26+
}

Classes/Service/VideoService.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Ayacoo\VideoValidator\Domain\Dto\ValidatorDemand;
88
use Ayacoo\VideoValidator\Domain\Repository\FileRepository;
99
use Ayacoo\VideoValidator\Event\ModifyValidatorEvent;
10+
use Ayacoo\VideoValidator\Event\ModifyVideoValidateEvent;
1011
use Ayacoo\VideoValidator\Service\Validator\AbstractVideoValidatorInterface;
1112
use Ayacoo\VideoValidator\Service\Validator\VimeoValidator;
1213
use Ayacoo\VideoValidator\Service\Validator\YoutubeValidator;
@@ -130,6 +131,11 @@ public function validate(ValidatorDemand $validatorDemand): void
130131
);
131132

132133
$this->fileRepository->updatePropertiesByFile($video['uid'], $properties);
134+
135+
// You want a special action after validation? Have a look at the documentation!
136+
$event = new ModifyVideoValidateEvent($file, $properties);
137+
$this->eventDispatcher->dispatch($event);
138+
133139
$this->io->progressAdvance(1);
134140
}
135141
$this->io->progressFinish();

README.md

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,46 @@ class YourReportService implements AbstractReportServiceInterface
400400
401401
```
402402

403-
### 5.4 Email settings
403+
### 5.4 Register your custom validate action
404+
405+
It is also possible to register your own actions during validation. For example,
406+
You can disable referenced content items.
407+
408+
### EventListener registration
409+
410+
```
411+
services:
412+
Extension\Namespace\Listener\VideoValidateListener:
413+
tags:
414+
- name: event.listener
415+
identifier: 'extensionkey/videovalidator'
416+
event: Ayacoo\VideoValidator\Event\ModifyVideoValidateEvent
417+
```
418+
419+
### EventListener
420+
421+
```
422+
<?php
423+
declare(strict_types=1);
424+
425+
namespace Extension\Namespace\Listener;
426+
427+
use Ayacoo\VideoValidator\Event\ModifyVideoValidateEvent;
428+
use TYPO3\CMS\Core\Utility\GeneralUtility;
429+
430+
class VideoValidateListener
431+
{
432+
public function dispatch(ModifyVideoValidateEvent $event): void
433+
{
434+
$file = $event->getFile();
435+
$properties = $event->getProperties();
436+
// Do your custom stuff e.g. custom action
437+
}
438+
}
439+
440+
```
441+
442+
### 5.5 Email settings
404443

405444
To define a sender for the email, the
406445
configuration ```$GLOBALS['TYPO3_CONF_VARS']['MAIL']['defaultMailFromAddress']```

0 commit comments

Comments
 (0)