diff options
author | Julius Härtl <jus@bitgrid.net> | 2022-10-25 12:53:10 +0200 |
---|---|---|
committer | Julius Härtl <jus@bitgrid.net> | 2022-10-27 14:31:33 +0200 |
commit | 07e94eca6f9fc8ea0bc814d90f6b1403bb9f707a (patch) | |
tree | f37c009a79e42642ed00e53eec83a4f490b1b600 /lib/private/Preview/Generator.php | |
parent | 8ee76c0d89c02dd359640deea53bb789bb982aca (diff) | |
download | nextcloud-server-07e94eca6f9fc8ea0bc814d90f6b1403bb9f707a.tar.gz nextcloud-server-07e94eca6f9fc8ea0bc814d90f6b1403bb9f707a.zip |
Emit typed event when preview is requested
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'lib/private/Preview/Generator.php')
-rw-r--r-- | lib/private/Preview/Generator.php | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/lib/private/Preview/Generator.php b/lib/private/Preview/Generator.php index ef44188da74..a49cc8e522e 100644 --- a/lib/private/Preview/Generator.php +++ b/lib/private/Preview/Generator.php @@ -29,6 +29,7 @@ */ namespace OC\Preview; +use OCP\EventDispatcher\IEventDispatcher; use OCP\Files\File; use OCP\Files\IAppData; use OCP\Files\InvalidPathException; @@ -40,6 +41,7 @@ use OCP\IConfig; use OCP\IImage; use OCP\IPreview; use OCP\IStreamImage; +use OCP\Preview\BeforePreviewFetchedEvent; use OCP\Preview\IProviderV2; use OCP\Preview\IVersionedPreviewFile; use Symfony\Component\EventDispatcher\EventDispatcherInterface; @@ -56,26 +58,23 @@ class Generator { /** @var GeneratorHelper */ private $helper; /** @var EventDispatcherInterface */ + private $legacyEventDispatcher; + /** @var IEventDispatcher */ private $eventDispatcher; - /** - * @param IConfig $config - * @param IPreview $previewManager - * @param IAppData $appData - * @param GeneratorHelper $helper - * @param EventDispatcherInterface $eventDispatcher - */ public function __construct( IConfig $config, IPreview $previewManager, IAppData $appData, GeneratorHelper $helper, - EventDispatcherInterface $eventDispatcher + EventDispatcherInterface $legacyEventDispatcher, + IEventDispatcher $eventDispatcher ) { $this->config = $config; $this->previewManager = $previewManager; $this->appData = $appData; $this->helper = $helper; + $this->legacyEventDispatcher = $legacyEventDispatcher; $this->eventDispatcher = $eventDispatcher; } @@ -102,10 +101,14 @@ class Generator { 'crop' => $crop, 'mode' => $mode, ]; - $this->eventDispatcher->dispatch( + + $this->legacyEventDispatcher->dispatch( IPreview::EVENT, new GenericEvent($file, $specification) ); + $this->eventDispatcher->dispatchTyped(new BeforePreviewFetchedEvent( + $file + )); // since we only ask for one preview, and the generate method return the last one it created, it returns the one we want return $this->generatePreviews($file, [$specification], $mimeType); |