Browse Source
Add full public interfaces
Signed-off-by: Julius Härtl <jus@bitgrid.net>
pull/33494/head
Julius Härtl
3 years ago
No known key found for this signature in database
GPG Key ID: 4C614C6ED2CDE6DF
7 changed files with
150 additions and
10 deletions
-
lib/private/Collaboration/Reference/FileReferenceProvider.php
-
lib/private/Collaboration/Reference/LinkReferenceProvider.php
-
lib/private/Collaboration/Reference/Reference.php
-
lib/private/Collaboration/Reference/ReferenceManager.php
-
lib/public/Collaboration/Reference/IReference.php
-
lib/public/Collaboration/Reference/IReferenceManager.php
-
lib/public/Collaboration/Reference/IReferenceProvider.php
|
|
|
@ -100,7 +100,7 @@ class FileReferenceProvider implements IReferenceProvider { |
|
|
|
]); |
|
|
|
} |
|
|
|
|
|
|
|
public function isGloballyCachable(): bool { |
|
|
|
public function isGloballyCacheable(): bool { |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -124,7 +124,7 @@ class LinkReferenceProvider implements IReferenceProvider { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public function isGloballyCachable(): bool { |
|
|
|
public function isGloballyCacheable(): bool { |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -25,7 +25,9 @@ declare(strict_types=1); |
|
|
|
|
|
|
|
namespace OC\Collaboration\Reference; |
|
|
|
|
|
|
|
class Reference implements \OCP\Collaboration\Reference\IReference, \JsonSerializable { |
|
|
|
use OCP\Collaboration\Reference\IReference; |
|
|
|
|
|
|
|
class Reference implements IReference { |
|
|
|
private string $reference; |
|
|
|
|
|
|
|
private bool $accessible = true; |
|
|
|
@ -120,7 +122,7 @@ class Reference implements \OCP\Collaboration\Reference\IReference, \JsonSeriali |
|
|
|
]; |
|
|
|
} |
|
|
|
|
|
|
|
public static function toCache(Reference $reference): array { |
|
|
|
public static function toCache(IReference $reference): array { |
|
|
|
return [ |
|
|
|
'id' => $reference->getId(), |
|
|
|
'title' => $reference->getTitle(), |
|
|
|
@ -134,7 +136,7 @@ class Reference implements \OCP\Collaboration\Reference\IReference, \JsonSeriali |
|
|
|
]; |
|
|
|
} |
|
|
|
|
|
|
|
public static function fromCache(array $cache): Reference { |
|
|
|
public static function fromCache(array $cache): IReference { |
|
|
|
$reference = new Reference($cache['id']); |
|
|
|
$reference->setTitle($cache['title']); |
|
|
|
$reference->setDescription($cache['description']); |
|
|
|
|
|
|
|
@ -100,7 +100,7 @@ class ReferenceManager implements IReferenceManager { |
|
|
|
|
|
|
|
private function getCacheKey(IReferenceProvider $provider, string $referenceId): string { |
|
|
|
return md5($referenceId) . ( |
|
|
|
$provider->isGloballyCachable() |
|
|
|
$provider->isGloballyCacheable() |
|
|
|
? '' |
|
|
|
: '-' . md5($provider->getCacheKey($referenceId)) |
|
|
|
); |
|
|
|
|
|
|
|
@ -22,10 +22,100 @@ |
|
|
|
|
|
|
|
namespace OCP\Collaboration\Reference; |
|
|
|
|
|
|
|
use OC\Collaboration\Reference\Reference; |
|
|
|
use JsonSerializable; |
|
|
|
|
|
|
|
interface IReference { |
|
|
|
/** |
|
|
|
* @since 25.0.0 |
|
|
|
*/ |
|
|
|
interface IReference extends JsonSerializable { |
|
|
|
|
|
|
|
/** |
|
|
|
* @since 25.0.0 |
|
|
|
*/ |
|
|
|
public function getId(): string; |
|
|
|
|
|
|
|
/** |
|
|
|
* @since 25.0.0 |
|
|
|
*/ |
|
|
|
public function setAccessible(bool $accessible): void; |
|
|
|
|
|
|
|
/** |
|
|
|
* @since 25.0.0 |
|
|
|
*/ |
|
|
|
public function setTitle(string $title): void; |
|
|
|
|
|
|
|
/** |
|
|
|
* @since 25.0.0 |
|
|
|
*/ |
|
|
|
public function getTitle(): string; |
|
|
|
|
|
|
|
/** |
|
|
|
* @since 25.0.0 |
|
|
|
*/ |
|
|
|
public function setDescription(?string $description): void; |
|
|
|
|
|
|
|
/** |
|
|
|
* @since 25.0.0 |
|
|
|
*/ |
|
|
|
public function getDescription(): ?string; |
|
|
|
|
|
|
|
/** |
|
|
|
* @since 25.0.0 |
|
|
|
*/ |
|
|
|
public function setImageUrl(?string $imageUrl): void; |
|
|
|
|
|
|
|
/** |
|
|
|
* @since 25.0.0 |
|
|
|
*/ |
|
|
|
public function getImageUrl(): ?string; |
|
|
|
|
|
|
|
/** |
|
|
|
* @since 25.0.0 |
|
|
|
*/ |
|
|
|
public function setImageContentType(?string $contentType): void; |
|
|
|
|
|
|
|
/** |
|
|
|
* @since 25.0.0 |
|
|
|
*/ |
|
|
|
public function getImageContentType(): ?string; |
|
|
|
|
|
|
|
/** |
|
|
|
* @since 25.0.0 |
|
|
|
*/ |
|
|
|
public function setUrl(?string $url): void; |
|
|
|
|
|
|
|
/** |
|
|
|
* @since 25.0.0 |
|
|
|
*/ |
|
|
|
public function getUrl(): ?string; |
|
|
|
|
|
|
|
/** |
|
|
|
* @since 25.0.0 |
|
|
|
*/ |
|
|
|
public function setRichObject(string $type, array $richObject): void; |
|
|
|
|
|
|
|
/** |
|
|
|
* @since 25.0.0 |
|
|
|
*/ |
|
|
|
public function getRichObjectType(): string; |
|
|
|
|
|
|
|
/** |
|
|
|
* @since 25.0.0 |
|
|
|
*/ |
|
|
|
public function getRichObject(): array; |
|
|
|
|
|
|
|
public static function toCache(Reference $reference): array; |
|
|
|
/** |
|
|
|
* @since 25.0.0 |
|
|
|
*/ |
|
|
|
public function getOpenGraphObject(): array; |
|
|
|
|
|
|
|
/** |
|
|
|
* @since 25.0.0 |
|
|
|
*/ |
|
|
|
public static function toCache(IReference $reference): array; |
|
|
|
|
|
|
|
/** |
|
|
|
* @since 25.0.0 |
|
|
|
*/ |
|
|
|
public static function fromCache(array $cache): IReference; |
|
|
|
} |
|
|
|
@ -22,10 +22,30 @@ |
|
|
|
|
|
|
|
namespace OCP\Collaboration\Reference; |
|
|
|
|
|
|
|
/** |
|
|
|
* @since 25.0.0 |
|
|
|
*/ |
|
|
|
interface IReferenceManager { |
|
|
|
/** |
|
|
|
* Return all reference identifiers within a string as an array |
|
|
|
* |
|
|
|
* @since 25.0.0 |
|
|
|
*/ |
|
|
|
public function extractReferences(string $text): array; |
|
|
|
|
|
|
|
/** |
|
|
|
* Resolve a given reference id to its metadata with all available providers |
|
|
|
* |
|
|
|
* This method has a fallback to always provide the open graph metadata, |
|
|
|
* but may still return null in case this is disabled or the fetching fails |
|
|
|
* @since 25.0.0 |
|
|
|
*/ |
|
|
|
public function resolveReference(string $reference): ?IReference; |
|
|
|
|
|
|
|
/** |
|
|
|
* Register a new reference provider |
|
|
|
* |
|
|
|
* @since 25.0.0 |
|
|
|
*/ |
|
|
|
public function registerReferenceProvider(IReferenceProvider $provider): void; |
|
|
|
} |
|
|
|
@ -22,9 +22,37 @@ |
|
|
|
|
|
|
|
namespace OCP\Collaboration\Reference; |
|
|
|
|
|
|
|
/** |
|
|
|
* @since 25.0.0 |
|
|
|
*/ |
|
|
|
interface IReferenceProvider { |
|
|
|
/** |
|
|
|
* Validate that a given reference identifier matches the current provider |
|
|
|
* |
|
|
|
* @since 25.0.0 |
|
|
|
*/ |
|
|
|
public function matchReference(string $referenceText): bool; |
|
|
|
|
|
|
|
/** |
|
|
|
* Return a reference with its metadata for a given reference identifier |
|
|
|
* |
|
|
|
* @since 25.0.0 |
|
|
|
*/ |
|
|
|
public function resolveReference(string $referenceText): ?IReference; |
|
|
|
public function isGloballyCachable(): bool; |
|
|
|
|
|
|
|
/** |
|
|
|
* Return true if the reference metadata can be globally cached |
|
|
|
* |
|
|
|
* @since 25.0.0 |
|
|
|
*/ |
|
|
|
public function isGloballyCacheable(): bool; |
|
|
|
|
|
|
|
/** |
|
|
|
* Return a custom cache key to be used for caching the metadata |
|
|
|
* This could be for example the current user id if the reference |
|
|
|
* access permissions are different for each user |
|
|
|
* |
|
|
|
* @since 25.0.0 |
|
|
|
*/ |
|
|
|
public function getCacheKey(string $referenceId): string; |
|
|
|
} |