diff --git a/Classes/EventListener/AfterFileAddedEventListener.php b/Classes/EventListener/AfterFileAddedEventListener.php index 5507cea..9e587fb 100644 --- a/Classes/EventListener/AfterFileAddedEventListener.php +++ b/Classes/EventListener/AfterFileAddedEventListener.php @@ -5,17 +5,19 @@ namespace Ayacoo\AwsMeta\EventListener; use Ayacoo\AwsMeta\Service\AwsImageRecognizeService; +use TYPO3\CMS\Core\Attribute\AsEventListener; use TYPO3\CMS\Core\Configuration\ExtensionConfiguration; use TYPO3\CMS\Core\Core\Environment; -use TYPO3\CMS\Core\Exception; use TYPO3\CMS\Core\Messaging\FlashMessage; use TYPO3\CMS\Core\Messaging\FlashMessageService; use TYPO3\CMS\Core\Resource\Event\AfterFileAddedEvent; use TYPO3\CMS\Core\Resource\File; -use TYPO3\CMS\Core\Resource\MetaDataAspect; use TYPO3\CMS\Core\Type\ContextualFeedbackSeverity; use TYPO3\CMS\Core\Utility\GeneralUtility; +#[AsEventListener( + identifier: 'ayacoo/aws-meta/after-file-added-event-listener' +)] class AfterFileAddedEventListener { private array $extConf; @@ -27,9 +29,6 @@ public function __construct( $this->extConf = $this->extensionConfiguration->get('aws_meta') ?? []; } - /** - * @throws Exception - */ public function setMetadata(AfterFileAddedEvent $event): AfterFileAddedEvent { if (!$this->hasAllAwsSettings()) { @@ -43,7 +42,6 @@ public function setMetadata(AfterFileAddedEvent $event): AfterFileAddedEvent $extension = strtolower($file->getExtension()); $imageExtensions = ['jpg', 'png']; if (in_array($extension, $imageExtensions, true) && $file->getPublicUrl() !== null) { - /** @var MetaDataAspect $metaData */ $metaData = $file->getMetaData(); $keywords = $this->awsImageRecognizeService->detectLabels($filePath); if ($keywords !== '') { diff --git a/Configuration/Services.yaml b/Configuration/Services.yaml index 6fa7881..cb92c88 100644 --- a/Configuration/Services.yaml +++ b/Configuration/Services.yaml @@ -6,9 +6,3 @@ services: Ayacoo\AwsMeta\: resource: '../Classes/*' exclude: '../Classes/Domain/Model/*' - Ayacoo\AwsMeta\EventListener\AfterFileAddedEventListener: - tags: - - name: event.listener - identifier: ayacoo/aws-meta/after-file-added-event-listener - event: TYPO3\CMS\Core\Resource\Event\AfterFileAddedEvent - method: 'setMetadata'