Compare commits

...

2 Commits

Author SHA1 Message Date
Julius Härtl 2c059dd606
Merge pull request #44952 from nextcloud/perf/44951/template-creator
perf(templates): Emit RegisterTemplateCreatorEvent to register template creators more lazy
2 weeks ago
Julius Härtl f9e235f7f1 perf(templates): Emit RegisterTemplateCreatorEvent to register template creators more lazy
Signed-off-by: Julius Härtl <jus@bitgrid.net>
3 weeks ago

@ -431,6 +431,7 @@ return array(
'OCP\\Files\\Template\\FileCreatedFromTemplateEvent' => $baseDir . '/lib/public/Files/Template/FileCreatedFromTemplateEvent.php',
'OCP\\Files\\Template\\ICustomTemplateProvider' => $baseDir . '/lib/public/Files/Template/ICustomTemplateProvider.php',
'OCP\\Files\\Template\\ITemplateManager' => $baseDir . '/lib/public/Files/Template/ITemplateManager.php',
'OCP\\Files\\Template\\RegisterTemplateCreatorEvent' => $baseDir . '/lib/public/Files/Template/RegisterTemplateCreatorEvent.php',
'OCP\\Files\\Template\\Template' => $baseDir . '/lib/public/Files/Template/Template.php',
'OCP\\Files\\Template\\TemplateFileCreator' => $baseDir . '/lib/public/Files/Template/TemplateFileCreator.php',
'OCP\\Files\\UnseekableException' => $baseDir . '/lib/public/Files/UnseekableException.php',

@ -464,6 +464,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
'OCP\\Files\\Template\\FileCreatedFromTemplateEvent' => __DIR__ . '/../../..' . '/lib/public/Files/Template/FileCreatedFromTemplateEvent.php',
'OCP\\Files\\Template\\ICustomTemplateProvider' => __DIR__ . '/../../..' . '/lib/public/Files/Template/ICustomTemplateProvider.php',
'OCP\\Files\\Template\\ITemplateManager' => __DIR__ . '/../../..' . '/lib/public/Files/Template/ITemplateManager.php',
'OCP\\Files\\Template\\RegisterTemplateCreatorEvent' => __DIR__ . '/../../..' . '/lib/public/Files/Template/RegisterTemplateCreatorEvent.php',
'OCP\\Files\\Template\\Template' => __DIR__ . '/../../..' . '/lib/public/Files/Template/Template.php',
'OCP\\Files\\Template\\TemplateFileCreator' => __DIR__ . '/../../..' . '/lib/public/Files/Template/TemplateFileCreator.php',
'OCP\\Files\\UnseekableException' => __DIR__ . '/../../..' . '/lib/public/Files/UnseekableException.php',

@ -40,6 +40,7 @@ use OCP\Files\NotFoundException;
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;
@ -119,6 +120,7 @@ class TemplateManager implements ITemplateManager {
if (!empty($this->types)) {
return $this->types;
}
$this->eventDispatcher->dispatchTyped(new RegisterTemplateCreatorEvent($this));
foreach ($this->registeredTypes as $registeredType) {
$this->types[] = $registeredType();
}

@ -0,0 +1,46 @@
<?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;
/**
* @since 30.0.0
*/
class RegisterTemplateCreatorEvent extends Event {
/**
* @since 30.0.0
*/
public function __construct(
private ITemplateManager $templateManager
) {
}
/**
* @since 30.0.0
*/
public function getTemplateManager(): ITemplateManager {
return $this->templateManager;
}
}
Loading…
Cancel
Save