1
0

BeforePreviewFetchedEvent.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. */
  18. class BeforePreviewFetchedEvent extends \OCP\EventDispatcher\Event {
  19. /**
  20. * @since 25.0.1
  21. */
  22. public function __construct(
  23. private Node $node,
  24. /** @deprecated 28.0.0 null deprecated **/
  25. private ?int $width = null,
  26. /** @deprecated 28.0.0 null deprecated **/
  27. private ?int $height = null,
  28. /** @deprecated 28.0.0 null deprecated **/
  29. private ?bool $crop = null,
  30. /** @deprecated 28.0.0 null deprecated **/
  31. private ?string $mode = null,
  32. ) {
  33. parent::__construct();
  34. }
  35. /**
  36. * @since 25.0.1
  37. */
  38. public function getNode(): Node {
  39. return $this->node;
  40. }
  41. /**
  42. * @since 28.0.0
  43. */
  44. public function getWidth(): ?int {
  45. return $this->width;
  46. }
  47. /**
  48. * @since 28.0.0
  49. */
  50. public function getHeight(): ?int {
  51. return $this->height;
  52. }
  53. /**
  54. * @since 28.0.0
  55. */
  56. public function isCrop(): ?bool {
  57. return $this->crop;
  58. }
  59. /**
  60. * @since 28.0.0
  61. * @return null|IPreview::MODE_FILL|IPreview::MODE_COVER
  62. */
  63. public function getMode(): ?string {
  64. return $this->mode;
  65. }
  66. }