1
0

ITemplateManager.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCP\Files\Template;
  8. use OCP\Files\GenericFileException;
  9. /**
  10. * @since 21.0.0
  11. */
  12. interface ITemplateManager {
  13. /**
  14. * Register a template type support
  15. *
  16. * @param callable(): TemplateFileCreator $callback A callback which returns the TemplateFileCreator instance to register
  17. * @since 21.0.0
  18. */
  19. public function registerTemplateFileCreator(callable $callback): void;
  20. /**
  21. * Get a list of available file creators
  22. *
  23. * @return array
  24. * @since 21.0.0
  25. */
  26. public function listCreators(): array;
  27. /**
  28. * Get a list of available file creators and their offered templates
  29. *
  30. * @return list<array{app: string, label: string, extension: string, iconClass: ?string, iconSvgInline: ?string, mimetypes: list<string>, ratio: ?float, actionLabel: string, templates: list<Template>}>
  31. * @since 21.0.0
  32. */
  33. public function listTemplates(): array;
  34. /**
  35. * @return bool
  36. * @since 21.0.0
  37. */
  38. public function hasTemplateDirectory(): bool;
  39. /**
  40. * @param string $path
  41. * @return void
  42. * @since 21.0.0
  43. */
  44. public function setTemplatePath(string $path): void;
  45. /**
  46. * @return string
  47. * @since 21.0.0
  48. */
  49. public function getTemplatePath(): string;
  50. /**
  51. * @param string|null $path
  52. * @param string|null $userId
  53. * @since 21.0.0
  54. */
  55. public function initializeTemplateDirectory(?string $path = null, ?string $userId = null, $copyTemplates = true): string;
  56. /**
  57. * @param string $filePath
  58. * @param string $templateId
  59. * @param string $templateType
  60. * @param array $templateFields Since 30.0.0
  61. * @return array
  62. * @throws GenericFileException
  63. * @since 21.0.0
  64. */
  65. public function createFromTemplate(string $filePath, string $templateId = '', string $templateType = 'user', array $templateFields = []): array;
  66. }