IReferenceManager.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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\Collaboration\Reference;
  8. /**
  9. * @since 25.0.0
  10. */
  11. interface IReferenceManager {
  12. /**
  13. * Return all reference identifiers within a string as an array
  14. *
  15. * @return string[] Array of found references (urls)
  16. * @since 25.0.0
  17. */
  18. public function extractReferences(string $text): array;
  19. /**
  20. * Resolve a given reference id to its metadata with all available providers
  21. *
  22. * This method has a fallback to always provide the open graph metadata,
  23. * but may still return null in case this is disabled or the fetching fails
  24. *
  25. * @since 25.0.0
  26. */
  27. public function resolveReference(string $referenceId): ?IReference;
  28. /**
  29. * Get a reference by its cache key
  30. *
  31. * @since 25.0.0
  32. */
  33. public function getReferenceByCacheKey(string $cacheKey): ?IReference;
  34. /**
  35. * Explicitly get a reference from the cache to avoid heavy fetches for cases
  36. * the cache can then be filled with a separate request from the frontend
  37. *
  38. * @since 25.0.0
  39. */
  40. public function getReferenceFromCache(string $referenceId): ?IReference;
  41. /**
  42. * Invalidate all cache entries with a prefix or just one if the cache key is provided
  43. *
  44. * @since 25.0.0
  45. */
  46. public function invalidateCache(string $cachePrefix, ?string $cacheKey = null): void;
  47. /**
  48. * Get information on discoverable reference providers (id, title, icon and order)
  49. * If the provider is searchable, also get the list of supported unified search providers
  50. *
  51. * @return IDiscoverableReferenceProvider[]
  52. * @since 26.0.0
  53. */
  54. public function getDiscoverableProviders(): array;
  55. /**
  56. * Update or set the last used timestamp for a provider
  57. *
  58. * @param string $userId
  59. * @param string $providerId
  60. * @param int|null $timestamp use current timestamp if null
  61. * @return bool
  62. * @since 26.0.0
  63. */
  64. public function touchProvider(string $userId, string $providerId, ?int $timestamp = null): bool;
  65. /**
  66. * Get all known last used timestamps for reference providers
  67. *
  68. * @return int[]
  69. * @since 26.0.0
  70. */
  71. public function getUserProviderTimestamps(): array;
  72. }