AbstractNodesEvent.php 977 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCP\Files\Events\Node;
  8. use OCP\EventDispatcher\Event;
  9. use OCP\EventDispatcher\IWebhookCompatibleEvent;
  10. use OCP\EventDispatcher\JsonSerializer;
  11. use OCP\Files\Node;
  12. /**
  13. * @since 20.0.0
  14. */
  15. abstract class AbstractNodesEvent extends Event implements IWebhookCompatibleEvent {
  16. /**
  17. * @since 20.0.0
  18. */
  19. public function __construct(
  20. private Node $source,
  21. private Node $target,
  22. ) {
  23. }
  24. /**
  25. * @since 20.0.0
  26. */
  27. public function getSource(): Node {
  28. return $this->source;
  29. }
  30. /**
  31. * @since 20.0.0
  32. */
  33. public function getTarget(): Node {
  34. return $this->target;
  35. }
  36. /**
  37. * @since 30.0.0
  38. */
  39. public function getWebhookSerializable(): array {
  40. return [
  41. 'source' => JsonSerializer::serializeFileInfo($this->source),
  42. 'target' => JsonSerializer::serializeFileInfo($this->target),
  43. ];
  44. }
  45. }