|
|
@@ -0,0 +1,28 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+namespace Drupal\mustikas_export\Hook;
|
|
|
+
|
|
|
+use Drupal\Core\Hook\Attribute\Hook;
|
|
|
+
|
|
|
+/**
|
|
|
+ * Hook implementations for mustikas_export.
|
|
|
+ */
|
|
|
+class FileDownloadHooks {
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Implements hook_file_download().
|
|
|
+ *
|
|
|
+ * Keelab anonüümsele kasutajale filedepot failide allalaadimise
|
|
|
+ * (D7 analoogia: filedepot nõudis sisselogimist).
|
|
|
+ */
|
|
|
+ #[Hook('file_download')]
|
|
|
+ public function fileDownload($uri): int|array|null {
|
|
|
+ if (str_starts_with($uri, 'private://filedepot/')) {
|
|
|
+ if (\Drupal::currentUser()->isAnonymous()) {
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return NULL;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|