Skip to content

Commit

Permalink
perf(templates): Emit RegisterTemplateCreatorEvent to register templa…
Browse files Browse the repository at this point in the history
…te creators more lazy

Signed-off-by: Julius Härtl <jus@bitgrid.net>
  • Loading branch information
juliushaertl committed Apr 22, 2024
1 parent 75612ec commit 7532009
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/private/Files/Template/TemplateManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
use OCP\Files\Template\FileCreatedFromTemplateEvent;
use OCP\Files\Template\ICustomTemplateProvider;
use OCP\Files\Template\ITemplateManager;
use OCP\Files\Template\RegisterTemplateCreatorEvent;
use OCP\Files\Template\Template;
use OCP\Files\Template\TemplateFileCreator;
use OCP\IConfig;
Expand Down Expand Up @@ -119,6 +120,7 @@ public function getTypes(): array {
if (!empty($this->types)) {
return $this->types;
}
$this->eventDispatcher->dispatchTyped(new RegisterTemplateCreatorEvent($this));
foreach ($this->registeredTypes as $registeredType) {
$this->types[] = $registeredType();
}
Expand Down
37 changes: 37 additions & 0 deletions lib/public/Files/Template/RegisterTemplateCreatorEvent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php
/**
* @copyright Copyright (c) 2024 Julius Härtl <jus@bitgrid.net>
*
* @author Julius Härtl <jus@bitgrid.net>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

namespace OCP\Files\Template;

use OCP\EventDispatcher\Event;

class RegisterTemplateCreatorEvent extends Event {

Check failure on line 27 in lib/public/Files/Template/RegisterTemplateCreatorEvent.php

View workflow job for this annotation

GitHub Actions / static-code-analysis-ocp

InvalidDocblock

lib/public/Files/Template/RegisterTemplateCreatorEvent.php:27:1: InvalidDocblock: PHPDoc is required for classes/interfaces in OCP. (see https://psalm.dev/008)

public function __construct(

Check failure on line 29 in lib/public/Files/Template/RegisterTemplateCreatorEvent.php

View workflow job for this annotation

GitHub Actions / static-code-analysis-ocp

InvalidDocblock

lib/public/Files/Template/RegisterTemplateCreatorEvent.php:29:2: InvalidDocblock: PHPDoc is required for methods in OCP. (see https://psalm.dev/008)
private ITemplateManager $templateManager
) {
}

public function getTemplateManager(): ITemplateManager {

Check failure on line 34 in lib/public/Files/Template/RegisterTemplateCreatorEvent.php

View workflow job for this annotation

GitHub Actions / static-code-analysis-ocp

InvalidDocblock

lib/public/Files/Template/RegisterTemplateCreatorEvent.php:34:2: InvalidDocblock: PHPDoc is required for methods in OCP. (see https://psalm.dev/008)
return $this->templateManager;
}
}

0 comments on commit 7532009

Please sign in to comment.