IReferenceManager.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. }