1
0

BeforePreviewFetchedEvent.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCP\Preview;
  8. use OCP\Files\Node;
  9. use OCP\IPreview;
  10. /**
  11. * Emitted before a file preview is being fetched.
  12. *
  13. * It can be used to block preview rendering by throwing a ``OCP\Files\NotFoundException``
  14. *
  15. * @since 25.0.1
  16. * @since 28.0.0 the constructor arguments ``$width``, ``$height``, ``$crop`` and ``$mode`` are no longer nullable.
  17. * @since 31.0.0 the constructor arguments ``$mimeType`` was added
  18. */
  19. class BeforePreviewFetchedEvent extends \OCP\EventDispatcher\Event {
  20. /**
  21. * @since 25.0.1
  22. */
  23. public function __construct(
  24. private Node $node,
  25. /** @deprecated 28.0.0 passing null is deprecated **/
  26. private ?int $width = null,
  27. /** @deprecated 28.0.0 passing null is deprecated **/
  28. private ?int $height = null,
  29. /** @deprecated 28.0.0 passing null is deprecated **/
  30. private ?bool $crop = null,
  31. /** @deprecated 28.0.0 passing null is deprecated **/
  32. private ?string $mode = null,
  33. private ?string $mimeType = null,
  34. ) {
  35. parent::__construct();
  36. }
  37. /**
  38. * @since 25.0.1
  39. */
  40. public function getNode(): Node {
  41. return $this->node;
  42. }
  43. /**
  44. * @since 28.0.0
  45. */
  46. public function getWidth(): ?int {
  47. return $this->width;
  48. }
  49. /**
  50. * @since 28.0.0
  51. */
  52. public function getHeight(): ?int {
  53. return $this->height;
  54. }
  55. /**
  56. * @since 28.0.0
  57. */
  58. public function isCrop(): ?bool {
  59. return $this->crop;
  60. }
  61. /**
  62. * @since 28.0.0
  63. * @return null|IPreview::MODE_FILL|IPreview::MODE_COVER
  64. */
  65. public function getMode(): ?string {
  66. return $this->mode;
  67. }
  68. /**
  69. * @since 31.0.0
  70. */
  71. public function getMimeType(): ?string {
  72. return $this->mimeType;
  73. }
  74. }