1
0

MetadataNamedEvent.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCP\FilesMetadata\Event;
  8. use OCP\Files\Node;
  9. use OCP\FilesMetadata\AMetadataEvent;
  10. use OCP\FilesMetadata\Model\IFilesMetadata;
  11. /**
  12. * MetadataNamedEvent is an event similar to MetadataBackgroundEvent completed with a target name,
  13. * used to limit the refresh of metadata only listeners capable of filtering themselves out.
  14. *
  15. * Meaning that when using this event, your app must implement a filter on the event's registered
  16. * name returned by getName()
  17. *
  18. * This event is mostly triggered when a registered name is added to the files scan
  19. * i.e. ./occ files:scan --generate-metadata [name]
  20. *
  21. * @see AMetadataEvent::getMetadata()
  22. * @see AMetadataEvent::getNode()
  23. * @see MetadataNamedEvent::getName()
  24. * @since 28.0.0
  25. */
  26. class MetadataNamedEvent extends AMetadataEvent {
  27. /**
  28. * @param Node $node
  29. * @param IFilesMetadata $metadata
  30. * @param string $name name assigned to the event
  31. *
  32. * @since 28.0.0
  33. */
  34. public function __construct(
  35. Node $node,
  36. IFilesMetadata $metadata,
  37. private string $name = ''
  38. ) {
  39. parent::__construct($node, $metadata);
  40. }
  41. /**
  42. * get the assigned name for the event.
  43. * This is used to know if your app is the called one when running the
  44. * ./occ files:scan --generate-metadata [name]
  45. *
  46. * @return string
  47. * @since 28.0.0
  48. */
  49. public function getName(): string {
  50. return $this->name;
  51. }
  52. }