From f69151e6261990d4a448b2755b8f77d8a805fc8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Mon, 26 Sep 2022 10:04:28 +0200 Subject: [PATCH 1/2] Move Reference class to public namespace MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- lib/composer/composer/autoload_classmap.php | 2 +- lib/composer/composer/autoload_static.php | 2 +- .../Collaboration/Reference/File/FileReferenceProvider.php | 2 +- lib/private/Collaboration/Reference/LinkReferenceProvider.php | 1 + lib/private/Collaboration/Reference/ReferenceManager.php | 1 + lib/{private => public}/Collaboration/Reference/Reference.php | 4 +--- 6 files changed, 6 insertions(+), 6 deletions(-) rename lib/{private => public}/Collaboration/Reference/Reference.php (98%) diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php index 9041b7ff2776a..441acc6e74eec 100644 --- a/lib/composer/composer/autoload_classmap.php +++ b/lib/composer/composer/autoload_classmap.php @@ -145,6 +145,7 @@ 'OCP\\Collaboration\\Reference\\IReference' => $baseDir . '/lib/public/Collaboration/Reference/IReference.php', 'OCP\\Collaboration\\Reference\\IReferenceManager' => $baseDir . '/lib/public/Collaboration/Reference/IReferenceManager.php', 'OCP\\Collaboration\\Reference\\IReferenceProvider' => $baseDir . '/lib/public/Collaboration/Reference/IReferenceProvider.php', + 'OCP\\Collaboration\\Reference\\Reference' => $baseDir . '/lib/public/Collaboration/Reference/Reference.php', 'OCP\\Collaboration\\Reference\\RenderReferenceEvent' => $baseDir . '/lib/public/Collaboration/Reference/RenderReferenceEvent.php', 'OCP\\Collaboration\\Resources\\CollectionException' => $baseDir . '/lib/public/Collaboration/Resources/CollectionException.php', 'OCP\\Collaboration\\Resources\\ICollection' => $baseDir . '/lib/public/Collaboration/Resources/ICollection.php', @@ -835,7 +836,6 @@ 'OC\\Collaboration\\Reference\\File\\FileReferenceEventListener' => $baseDir . '/lib/private/Collaboration/Reference/File/FileReferenceEventListener.php', 'OC\\Collaboration\\Reference\\File\\FileReferenceProvider' => $baseDir . '/lib/private/Collaboration/Reference/File/FileReferenceProvider.php', 'OC\\Collaboration\\Reference\\LinkReferenceProvider' => $baseDir . '/lib/private/Collaboration/Reference/LinkReferenceProvider.php', - 'OC\\Collaboration\\Reference\\Reference' => $baseDir . '/lib/private/Collaboration/Reference/Reference.php', 'OC\\Collaboration\\Reference\\ReferenceManager' => $baseDir . '/lib/private/Collaboration/Reference/ReferenceManager.php', 'OC\\Collaboration\\Resources\\Collection' => $baseDir . '/lib/private/Collaboration/Resources/Collection.php', 'OC\\Collaboration\\Resources\\Listener' => $baseDir . '/lib/private/Collaboration/Resources/Listener.php', diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php index 7c5d5c2728e15..39ce9db1dcc4b 100644 --- a/lib/composer/composer/autoload_static.php +++ b/lib/composer/composer/autoload_static.php @@ -178,6 +178,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2 'OCP\\Collaboration\\Reference\\IReference' => __DIR__ . '/../../..' . '/lib/public/Collaboration/Reference/IReference.php', 'OCP\\Collaboration\\Reference\\IReferenceManager' => __DIR__ . '/../../..' . '/lib/public/Collaboration/Reference/IReferenceManager.php', 'OCP\\Collaboration\\Reference\\IReferenceProvider' => __DIR__ . '/../../..' . '/lib/public/Collaboration/Reference/IReferenceProvider.php', + 'OCP\\Collaboration\\Reference\\Reference' => __DIR__ . '/../../..' . '/lib/public/Collaboration/Reference/Reference.php', 'OCP\\Collaboration\\Reference\\RenderReferenceEvent' => __DIR__ . '/../../..' . '/lib/public/Collaboration/Reference/RenderReferenceEvent.php', 'OCP\\Collaboration\\Resources\\CollectionException' => __DIR__ . '/../../..' . '/lib/public/Collaboration/Resources/CollectionException.php', 'OCP\\Collaboration\\Resources\\ICollection' => __DIR__ . '/../../..' . '/lib/public/Collaboration/Resources/ICollection.php', @@ -868,7 +869,6 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2 'OC\\Collaboration\\Reference\\File\\FileReferenceEventListener' => __DIR__ . '/../../..' . '/lib/private/Collaboration/Reference/File/FileReferenceEventListener.php', 'OC\\Collaboration\\Reference\\File\\FileReferenceProvider' => __DIR__ . '/../../..' . '/lib/private/Collaboration/Reference/File/FileReferenceProvider.php', 'OC\\Collaboration\\Reference\\LinkReferenceProvider' => __DIR__ . '/../../..' . '/lib/private/Collaboration/Reference/LinkReferenceProvider.php', - 'OC\\Collaboration\\Reference\\Reference' => __DIR__ . '/../../..' . '/lib/private/Collaboration/Reference/Reference.php', 'OC\\Collaboration\\Reference\\ReferenceManager' => __DIR__ . '/../../..' . '/lib/private/Collaboration/Reference/ReferenceManager.php', 'OC\\Collaboration\\Resources\\Collection' => __DIR__ . '/../../..' . '/lib/private/Collaboration/Resources/Collection.php', 'OC\\Collaboration\\Resources\\Listener' => __DIR__ . '/../../..' . '/lib/private/Collaboration/Resources/Listener.php', diff --git a/lib/private/Collaboration/Reference/File/FileReferenceProvider.php b/lib/private/Collaboration/Reference/File/FileReferenceProvider.php index 39cdb62b09ad0..9109cbf73774e 100644 --- a/lib/private/Collaboration/Reference/File/FileReferenceProvider.php +++ b/lib/private/Collaboration/Reference/File/FileReferenceProvider.php @@ -24,10 +24,10 @@ namespace OC\Collaboration\Reference\File; -use OC\Collaboration\Reference\Reference; use OC\User\NoUserException; use OCP\Collaboration\Reference\IReference; use OCP\Collaboration\Reference\IReferenceProvider; +use OCP\Collaboration\Reference\Reference; use OCP\Files\InvalidPathException; use OCP\Files\IRootFolder; use OCP\Files\Node; diff --git a/lib/private/Collaboration/Reference/LinkReferenceProvider.php b/lib/private/Collaboration/Reference/LinkReferenceProvider.php index 36fbdd0b16821..5597df1ca978d 100644 --- a/lib/private/Collaboration/Reference/LinkReferenceProvider.php +++ b/lib/private/Collaboration/Reference/LinkReferenceProvider.php @@ -32,6 +32,7 @@ use OC\SystemConfig; use OCP\Collaboration\Reference\IReference; use OCP\Collaboration\Reference\IReferenceProvider; +use OCP\Collaboration\Reference\Reference; use OCP\Files\AppData\IAppDataFactory; use OCP\Files\NotFoundException; use OCP\Http\Client\IClientService; diff --git a/lib/private/Collaboration/Reference/ReferenceManager.php b/lib/private/Collaboration/Reference/ReferenceManager.php index 304d693804f52..a11d92fe2a9ff 100644 --- a/lib/private/Collaboration/Reference/ReferenceManager.php +++ b/lib/private/Collaboration/Reference/ReferenceManager.php @@ -29,6 +29,7 @@ use OCP\Collaboration\Reference\IReference; use OCP\Collaboration\Reference\IReferenceManager; use OCP\Collaboration\Reference\IReferenceProvider; +use OCP\Collaboration\Reference\Reference; use OCP\ICache; use OCP\ICacheFactory; use OCP\IURLGenerator; diff --git a/lib/private/Collaboration/Reference/Reference.php b/lib/public/Collaboration/Reference/Reference.php similarity index 98% rename from lib/private/Collaboration/Reference/Reference.php rename to lib/public/Collaboration/Reference/Reference.php index 22dc57782d85c..59619bdd5d919 100644 --- a/lib/private/Collaboration/Reference/Reference.php +++ b/lib/public/Collaboration/Reference/Reference.php @@ -23,9 +23,7 @@ * along with this program. If not, see . */ -namespace OC\Collaboration\Reference; - -use OCP\Collaboration\Reference\IReference; +namespace OCP\Collaboration\Reference; class Reference implements IReference { private string $reference; From 042474bb12f925ee94ad01f8e1b6120114d055ec Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 26 Sep 2022 11:26:34 +0200 Subject: [PATCH 2/2] Add since Signed-off-by: Joas Schilling --- .../Collaboration/Reference/Reference.php | 106 ++++++++++++++++-- 1 file changed, 97 insertions(+), 9 deletions(-) diff --git a/lib/public/Collaboration/Reference/Reference.php b/lib/public/Collaboration/Reference/Reference.php index 59619bdd5d919..07da3399a1e48 100644 --- a/lib/public/Collaboration/Reference/Reference.php +++ b/lib/public/Collaboration/Reference/Reference.php @@ -25,81 +25,147 @@ namespace OCP\Collaboration\Reference; +/** + * @since 25.0.0 + */ class Reference implements IReference { - private string $reference; + protected string $reference; - private bool $accessible = true; + protected bool $accessible = true; - private ?string $title = null; - private ?string $description = null; - private ?string $imageUrl = null; - private ?string $contentType = null; - private ?string $url = null; + protected ?string $title = null; + protected ?string $description = null; + protected ?string $imageUrl = null; + protected ?string $contentType = null; + protected ?string $url = null; - private ?string $richObjectType = null; - private ?array $richObject = null; + protected ?string $richObjectType = null; + protected ?array $richObject = null; + /** + * @since 25.0.0 + */ public function __construct(string $reference) { $this->reference = $reference; } + /** + * @inheritdoc + * @since 25.0.0 + */ public function getId(): string { return $this->reference; } + /** + * @inheritdoc + * @since 25.0.0 + */ public function setAccessible(bool $accessible): void { $this->accessible = $accessible; } + /** + * @inheritdoc + * @since 25.0.0 + */ public function getAccessible(): bool { return $this->accessible; } + /** + * @inheritdoc + * @since 25.0.0 + */ public function setTitle(string $title): void { $this->title = $title; } + /** + * @inheritdoc + * @since 25.0.0 + */ public function getTitle(): string { return $this->title ?? $this->reference; } + /** + * @inheritdoc + * @since 25.0.0 + */ public function setDescription(?string $description): void { $this->description = $description; } + /** + * @inheritdoc + * @since 25.0.0 + */ public function getDescription(): ?string { return $this->description; } + /** + * @inheritdoc + * @since 25.0.0 + */ public function setImageUrl(?string $imageUrl): void { $this->imageUrl = $imageUrl; } + /** + * @inheritdoc + * @since 25.0.0 + */ public function getImageUrl(): ?string { return $this->imageUrl; } + /** + * @inheritdoc + * @since 25.0.0 + */ public function setImageContentType(?string $contentType): void { $this->contentType = $contentType; } + /** + * @inheritdoc + * @since 25.0.0 + */ public function getImageContentType(): ?string { return $this->contentType; } + /** + * @inheritdoc + * @since 25.0.0 + */ public function setUrl(?string $url): void { $this->url = $url; } + /** + * @inheritdoc + * @since 25.0.0 + */ public function getUrl(): ?string { return $this->url; } + /** + * @inheritdoc + * @since 25.0.0 + */ public function setRichObject(string $type, ?array $richObject): void { $this->richObjectType = $type; $this->richObject = $richObject; } + /** + * @inheritdoc + * @since 25.0.0 + */ public function getRichObjectType(): string { if ($this->richObjectType === null) { return 'open-graph'; @@ -107,6 +173,10 @@ public function getRichObjectType(): string { return $this->richObjectType; } + /** + * @inheritdoc + * @since 25.0.0 + */ public function getRichObject(): array { if ($this->richObject === null) { return $this->getOpenGraphObject(); @@ -114,6 +184,10 @@ public function getRichObject(): array { return $this->richObject; } + /** + * @inheritdoc + * @since 25.0.0 + */ public function getOpenGraphObject(): array { return [ 'id' => $this->getId(), @@ -124,6 +198,11 @@ public function getOpenGraphObject(): array { ]; } + /** + * @param IReference $reference + * @return array + * @since 25.0.0 + */ public static function toCache(IReference $reference): array { return [ 'id' => $reference->getId(), @@ -138,6 +217,11 @@ public static function toCache(IReference $reference): array { ]; } + /** + * @param array $cache + * @return IReference + * @since 25.0.0 + */ public static function fromCache(array $cache): IReference { $reference = new Reference($cache['id']); $reference->setTitle($cache['title']); @@ -150,6 +234,10 @@ public static function fromCache(array $cache): IReference { return $reference; } + /** + * @inheritdoc + * @since 25.0.0 + */ public function jsonSerialize() { return [ 'richObjectType' => $this->getRichObjectType(),