MetadataNamedEvent.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * @copyright 2023 Maxence Lange <maxence@artificial-owl.com>
  5. *
  6. * @author Maxence Lange <maxence@artificial-owl.com>
  7. *
  8. * @license GNU AGPL version 3 or any later version
  9. *
  10. * This program is free software: you can redistribute it and/or modify
  11. * it under the terms of the GNU Affero General Public License as
  12. * published by the Free Software Foundation, either version 3 of the
  13. * License, or (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU Affero General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU Affero General Public License
  21. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  22. *
  23. */
  24. namespace OCP\FilesMetadata\Event;
  25. use OCP\Files\Node;
  26. use OCP\FilesMetadata\AMetadataEvent;
  27. use OCP\FilesMetadata\Model\IFilesMetadata;
  28. /**
  29. * MetadataNamedEvent is an event similar to MetadataBackgroundEvent completed with a target name,
  30. * used to limit the refresh of metadata only listeners capable of filtering themselves out.
  31. *
  32. * Meaning that when using this event, your app must implement a filter on the event's registered
  33. * name returned by getName()
  34. *
  35. * This event is mostly triggered when a registered name is added to the files scan
  36. * i.e. ./occ files:scan --generate-metadata [name]
  37. *
  38. * @see AMetadataEvent::getMetadata()
  39. * @see AMetadataEvent::getNode()
  40. * @see MetadataNamedEvent::getName()
  41. * @since 28.0.0
  42. */
  43. class MetadataNamedEvent extends AMetadataEvent {
  44. /**
  45. * @param Node $node
  46. * @param IFilesMetadata $metadata
  47. * @param string $name name assigned to the event
  48. *
  49. * @since 28.0.0
  50. */
  51. public function __construct(
  52. Node $node,
  53. IFilesMetadata $metadata,
  54. private string $name = ''
  55. ) {
  56. parent::__construct($node, $metadata);
  57. }
  58. /**
  59. * get the assigned name for the event.
  60. * This is used to know if your app is the called one when running the
  61. * ./occ files:scan --generate-metadata [name]
  62. *
  63. * @return string
  64. * @since 28.0.0
  65. */
  66. public function getName(): string {
  67. return $this->name;
  68. }
  69. }