File tree Expand file tree Collapse file tree 2 files changed +20
-6
lines changed Expand file tree Collapse file tree 2 files changed +20
-6
lines changed Original file line number Diff line number Diff line change 20
20
use OCP \AppFramework \Bootstrap \IBootContext ;
21
21
use OCP \AppFramework \Bootstrap \IBootstrap ;
22
22
use OCP \AppFramework \Bootstrap \IRegistrationContext ;
23
+ use OCP \Files \Template \ITemplateManager ;
23
24
use OCP \Files \Template \RegisterTemplateCreatorEvent ;
25
+ use OCP \IL10N ;
24
26
use OCP \Security \CSP \AddContentSecurityPolicyEvent ;
27
+ use OCP \Util ;
25
28
26
29
/**
27
30
* @psalm-suppress UndefinedClass
@@ -44,6 +47,13 @@ public function register(IRegistrationContext $context): void {
44
47
}
45
48
46
49
public function boot (IBootContext $ context ): void {
47
-
50
+ [$ major ] = Util::getVersion ();
51
+ if ($ major < 30 ) {
52
+ $ context ->injectFn (function (ITemplateManager $ templateManager , IL10N $ l10n ) use ($ major ) {
53
+ $ templateManager ->registerTemplateFileCreator (function () use ($ l10n ) {
54
+ return RegisterTemplateCreatorListener::getTemplateFileCreator ($ l10n );
55
+ });
56
+ });
57
+ }
48
58
}
49
59
}
Original file line number Diff line number Diff line change @@ -32,11 +32,15 @@ public function handle(Event $event): void {
32
32
33
33
34
34
$ event ->getTemplateManager ()->registerTemplateFileCreator (function () {
35
- $ whiteboard = new TemplateFileCreator (Application::APP_ID , $ this ->l10n ->t ('New whiteboard ' ), '.whiteboard ' );
36
- $ whiteboard ->addMimetype ('application/vnd.excalidraw+json ' );
37
- $ whiteboard ->setIconSvgInline (file_get_contents (__DIR__ . '/../../img/app-filetype.svg ' ));
38
- $ whiteboard ->setActionLabel ($ this ->l10n ->t ('Create new whiteboard ' ));
39
- return $ whiteboard ;
35
+ return self ::getTemplateFileCreator ($ this ->l10n );
40
36
});
41
37
}
38
+
39
+ public static function getTemplateFileCreator (IL10N $ l10n ): TemplateFileCreator {
40
+ $ whiteboard = new TemplateFileCreator (Application::APP_ID , $ l10n ->t ('New whiteboard ' ), '.whiteboard ' );
41
+ $ whiteboard ->addMimetype ('application/vnd.excalidraw+json ' );
42
+ $ whiteboard ->setIconSvgInline (file_get_contents (__DIR__ . '/../../img/app-filetype.svg ' ));
43
+ $ whiteboard ->setActionLabel ($ l10n ->t ('Create new whiteboard ' ));
44
+ return $ whiteboard ;
45
+ }
42
46
}
You can’t perform that action at this time.
0 commit comments