aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorElizabeth Danzberger <lizzy7128@tutanota.de>2024-07-05 12:47:01 -0400
committerJulius Härtl <jus@bitgrid.net>2024-07-25 11:11:38 +0200
commit05ed5aa230fde4e2c9ccf9c18c1e8766dbc9ad8d (patch)
tree28048a96aee44958081e9f09181d70cce3e16b5b
parente65f318fdfad720a7d0a69a4dd2b1963af008b09 (diff)
downloadnextcloud-server-05ed5aa230fde4e2c9ccf9c18c1e8766dbc9ad8d.tar.gz
nextcloud-server-05ed5aa230fde4e2c9ccf9c18c1e8766dbc9ad8d.zip
fix: Emit new `BeforeGetTemplates` event
Signed-off-by: Elizabeth Danzberger <lizzy7128@tutanota.de>
-rw-r--r--lib/composer/composer/autoload_classmap.php1
-rw-r--r--lib/composer/composer/autoload_static.php1
-rw-r--r--lib/private/Files/Template/TemplateManager.php3
-rw-r--r--lib/public/Files/Template/BeforeGetTemplatesEvent.php24
-rw-r--r--lib/public/Files/Template/Field.php4
-rw-r--r--lib/public/Files/Template/FieldType.php2
-rw-r--r--lib/public/Files/Template/Template.php2
7 files changed, 31 insertions, 6 deletions
diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php
index 9244ce9003b..6d8f1578997 100644
--- a/lib/composer/composer/autoload_classmap.php
+++ b/lib/composer/composer/autoload_classmap.php
@@ -435,6 +435,7 @@ return array(
'OCP\\Files\\Storage\\IStorage' => $baseDir . '/lib/public/Files/Storage/IStorage.php',
'OCP\\Files\\Storage\\IStorageFactory' => $baseDir . '/lib/public/Files/Storage/IStorageFactory.php',
'OCP\\Files\\Storage\\IWriteStreamStorage' => $baseDir . '/lib/public/Files/Storage/IWriteStreamStorage.php',
+ 'OCP\\Files\\Template\\BeforeGetTemplatesEvent' => $baseDir . '/lib/public/Files/Template/BeforeGetTemplatesEvent.php',
'OCP\\Files\\Template\\Field' => $baseDir . '/lib/public/Files/Template/Field.php',
'OCP\\Files\\Template\\FieldType' => $baseDir . '/lib/public/Files/Template/FieldType.php',
'OCP\\Files\\Template\\FileCreatedFromTemplateEvent' => $baseDir . '/lib/public/Files/Template/FileCreatedFromTemplateEvent.php',
diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php
index c0931bc5940..769a6c300ca 100644
--- a/lib/composer/composer/autoload_static.php
+++ b/lib/composer/composer/autoload_static.php
@@ -468,6 +468,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
'OCP\\Files\\Storage\\IStorage' => __DIR__ . '/../../..' . '/lib/public/Files/Storage/IStorage.php',
'OCP\\Files\\Storage\\IStorageFactory' => __DIR__ . '/../../..' . '/lib/public/Files/Storage/IStorageFactory.php',
'OCP\\Files\\Storage\\IWriteStreamStorage' => __DIR__ . '/../../..' . '/lib/public/Files/Storage/IWriteStreamStorage.php',
+ 'OCP\\Files\\Template\\BeforeGetTemplatesEvent' => __DIR__ . '/../../..' . '/lib/public/Files/Template/BeforeGetTemplatesEvent.php',
'OCP\\Files\\Template\\Field' => __DIR__ . '/../../..' . '/lib/public/Files/Template/Field.php',
'OCP\\Files\\Template\\FieldType' => __DIR__ . '/../../..' . '/lib/public/Files/Template/FieldType.php',
'OCP\\Files\\Template\\FileCreatedFromTemplateEvent' => __DIR__ . '/../../..' . '/lib/public/Files/Template/FileCreatedFromTemplateEvent.php',
diff --git a/lib/private/Files/Template/TemplateManager.php b/lib/private/Files/Template/TemplateManager.php
index 8362298b831..e9014c7c17e 100644
--- a/lib/private/Files/Template/TemplateManager.php
+++ b/lib/private/Files/Template/TemplateManager.php
@@ -18,6 +18,7 @@ use OCP\Files\GenericFileException;
use OCP\Files\IRootFolder;
use OCP\Files\Node;
use OCP\Files\NotFoundException;
+use OCP\Files\Template\BeforeGetTemplatesEvent;
use OCP\Files\Template\FileCreatedFromTemplateEvent;
use OCP\Files\Template\ICustomTemplateProvider;
use OCP\Files\Template\ITemplateManager;
@@ -204,6 +205,8 @@ class TemplateManager implements ITemplateManager {
}
}
+ $this->eventDispatcher->dispatchTyped(new BeforeGetTemplatesEvent($templates));
+
return $templates;
}
diff --git a/lib/public/Files/Template/BeforeGetTemplatesEvent.php b/lib/public/Files/Template/BeforeGetTemplatesEvent.php
new file mode 100644
index 00000000000..dee4154b98d
--- /dev/null
+++ b/lib/public/Files/Template/BeforeGetTemplatesEvent.php
@@ -0,0 +1,24 @@
+<?php
+
+/**
+ * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+
+namespace OCP\Files\Template;
+
+use OCP\EventDispatcher\Event;
+
+class BeforeGetTemplatesEvent extends Event {
+ private array $templates;
+
+ public function __construct(array $templates) {
+ parent::__construct();
+
+ $this->templates = $templates;
+ }
+
+ public function getTemplates(): array {
+ return $this->templates;
+ }
+}
diff --git a/lib/public/Files/Template/Field.php b/lib/public/Files/Template/Field.php
index 35e937da78f..ccab7f48b00 100644
--- a/lib/public/Files/Template/Field.php
+++ b/lib/public/Files/Template/Field.php
@@ -7,12 +7,10 @@
namespace OCP\Files\Template;
-use OCP\Files\Template\FieldType;
-
class Field {
public FieldType $type;
public function __construct(FieldType $type) {
$this->type = $type;
}
-} \ No newline at end of file
+}
diff --git a/lib/public/Files/Template/FieldType.php b/lib/public/Files/Template/FieldType.php
index 27873aa9067..aaf66ce8d27 100644
--- a/lib/public/Files/Template/FieldType.php
+++ b/lib/public/Files/Template/FieldType.php
@@ -9,4 +9,4 @@ namespace OCP\Files\Template;
enum FieldType {
case PlainText;
-} \ No newline at end of file
+}
diff --git a/lib/public/Files/Template/Template.php b/lib/public/Files/Template/Template.php
index 3bebab2c3a8..634935d212e 100644
--- a/lib/public/Files/Template/Template.php
+++ b/lib/public/Files/Template/Template.php
@@ -9,8 +9,6 @@ declare(strict_types=1);
namespace OCP\Files\Template;
use OCP\Files\File;
-use OCP\Files\Template\Field;
-use OCP\Files\Template\FieldType;
/**
* @since 21.0.0