ITemplateManager.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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 array
  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. * @return array
  60. * @throws GenericFileException
  61. * @since 21.0.0
  62. */
  63. public function createFromTemplate(string $filePath, string $templateId = '', string $templateType = 'user'): array;
  64. }