1
0

IReferenceManager.php 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * @copyright Copyright (c) 2022 Julius Härtl <jus@bitgrid.net>
  5. *
  6. * @author Julius Härtl <jus@bitgrid.net>
  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. namespace OCP\Collaboration\Reference;
  24. /**
  25. * @since 25.0.0
  26. */
  27. interface IReferenceManager {
  28. /**
  29. * Return all reference identifiers within a string as an array
  30. *
  31. * @return string[] Array of found references (urls)
  32. * @since 25.0.0
  33. */
  34. public function extractReferences(string $text): array;
  35. /**
  36. * Resolve a given reference id to its metadata with all available providers
  37. *
  38. * This method has a fallback to always provide the open graph metadata,
  39. * but may still return null in case this is disabled or the fetching fails
  40. *
  41. * @since 25.0.0
  42. */
  43. public function resolveReference(string $referenceId): ?IReference;
  44. /**
  45. * Get a reference by its cache key
  46. *
  47. * @since 25.0.0
  48. */
  49. public function getReferenceByCacheKey(string $cacheKey): ?IReference;
  50. /**
  51. * Explicitly get a reference from the cache to avoid heavy fetches for cases
  52. * the cache can then be filled with a separate request from the frontend
  53. *
  54. * @since 25.0.0
  55. */
  56. public function getReferenceFromCache(string $referenceId): ?IReference;
  57. /**
  58. * Invalidate all cache entries with a prefix or just one if the cache key is provided
  59. *
  60. * @since 25.0.0
  61. */
  62. public function invalidateCache(string $cachePrefix, ?string $cacheKey = null): void;
  63. /**
  64. * Get information on discoverable reference providers (id, title, icon and order)
  65. * If the provider is searchable, also get the list of supported unified search providers
  66. *
  67. * @return IDiscoverableReferenceProvider[]
  68. * @since 26.0.0
  69. */
  70. public function getDiscoverableProviders(): array;
  71. /**
  72. * Update or set the last used timestamp for a provider
  73. *
  74. * @param string $userId
  75. * @param string $providerId
  76. * @param int|null $timestamp use current timestamp if null
  77. * @return bool
  78. * @since 26.0.0
  79. */
  80. public function touchProvider(string $userId, string $providerId, ?int $timestamp = null): bool;
  81. /**
  82. * Get all known last used timestamps for reference providers
  83. *
  84. * @return int[]
  85. * @since 26.0.0
  86. */
  87. public function getUserProviderTimestamps(): array;
  88. }