TemplateManager.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  6. * @author Julius Härtl <jus@bitgrid.net>
  7. * @author Morris Jobke <hey@morrisjobke.de>
  8. * @author Robin Appelman <robin@icewind.nl>
  9. * @author Robin McCorkell <robin@mccorkell.me.uk>
  10. *
  11. * @license AGPL-3.0
  12. *
  13. * This code is free software: you can redistribute it and/or modify
  14. * it under the terms of the GNU Affero General Public License, version 3,
  15. * as published by the Free Software Foundation.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU Affero General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU Affero General Public License, version 3,
  23. * along with this program. If not, see <http://www.gnu.org/licenses/>
  24. *
  25. */
  26. namespace OC\Files\Type;
  27. /**
  28. * @deprecated 18.0.0
  29. */
  30. class TemplateManager {
  31. protected $templates = [];
  32. public function registerTemplate($mimetype, $path) {
  33. $this->templates[$mimetype] = $path;
  34. }
  35. /**
  36. * get the path of the template for a mimetype
  37. *
  38. * @deprecated 18.0.0
  39. * @param string $mimetype
  40. * @return string|null
  41. */
  42. public function getTemplatePath($mimetype) {
  43. if (isset($this->templates[$mimetype])) {
  44. return $this->templates[$mimetype];
  45. } else {
  46. return null;
  47. }
  48. }
  49. /**
  50. * get the template content for a mimetype
  51. *
  52. * @deprecated 18.0.0
  53. * @param string $mimetype
  54. * @return string
  55. */
  56. public function getTemplate($mimetype) {
  57. $path = $this->getTemplatePath($mimetype);
  58. if ($path) {
  59. return file_get_contents($path);
  60. } else {
  61. return '';
  62. }
  63. }
  64. }