Skip to content

Commit 4a034ac

Browse files
authored
Merge pull request #34249 from nextcloud/bugfix/noid/reference-public
Move Reference class to public namespace
2 parents 671c365 + 042474b commit 4a034ac

File tree

6 files changed

+103
-15
lines changed

6 files changed

+103
-15
lines changed

lib/composer/composer/autoload_classmap.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@
145145
'OCP\\Collaboration\\Reference\\IReference' => $baseDir . '/lib/public/Collaboration/Reference/IReference.php',
146146
'OCP\\Collaboration\\Reference\\IReferenceManager' => $baseDir . '/lib/public/Collaboration/Reference/IReferenceManager.php',
147147
'OCP\\Collaboration\\Reference\\IReferenceProvider' => $baseDir . '/lib/public/Collaboration/Reference/IReferenceProvider.php',
148+
'OCP\\Collaboration\\Reference\\Reference' => $baseDir . '/lib/public/Collaboration/Reference/Reference.php',
148149
'OCP\\Collaboration\\Reference\\RenderReferenceEvent' => $baseDir . '/lib/public/Collaboration/Reference/RenderReferenceEvent.php',
149150
'OCP\\Collaboration\\Resources\\CollectionException' => $baseDir . '/lib/public/Collaboration/Resources/CollectionException.php',
150151
'OCP\\Collaboration\\Resources\\ICollection' => $baseDir . '/lib/public/Collaboration/Resources/ICollection.php',
@@ -835,7 +836,6 @@
835836
'OC\\Collaboration\\Reference\\File\\FileReferenceEventListener' => $baseDir . '/lib/private/Collaboration/Reference/File/FileReferenceEventListener.php',
836837
'OC\\Collaboration\\Reference\\File\\FileReferenceProvider' => $baseDir . '/lib/private/Collaboration/Reference/File/FileReferenceProvider.php',
837838
'OC\\Collaboration\\Reference\\LinkReferenceProvider' => $baseDir . '/lib/private/Collaboration/Reference/LinkReferenceProvider.php',
838-
'OC\\Collaboration\\Reference\\Reference' => $baseDir . '/lib/private/Collaboration/Reference/Reference.php',
839839
'OC\\Collaboration\\Reference\\ReferenceManager' => $baseDir . '/lib/private/Collaboration/Reference/ReferenceManager.php',
840840
'OC\\Collaboration\\Resources\\Collection' => $baseDir . '/lib/private/Collaboration/Resources/Collection.php',
841841
'OC\\Collaboration\\Resources\\Listener' => $baseDir . '/lib/private/Collaboration/Resources/Listener.php',

lib/composer/composer/autoload_static.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
178178
'OCP\\Collaboration\\Reference\\IReference' => __DIR__ . '/../../..' . '/lib/public/Collaboration/Reference/IReference.php',
179179
'OCP\\Collaboration\\Reference\\IReferenceManager' => __DIR__ . '/../../..' . '/lib/public/Collaboration/Reference/IReferenceManager.php',
180180
'OCP\\Collaboration\\Reference\\IReferenceProvider' => __DIR__ . '/../../..' . '/lib/public/Collaboration/Reference/IReferenceProvider.php',
181+
'OCP\\Collaboration\\Reference\\Reference' => __DIR__ . '/../../..' . '/lib/public/Collaboration/Reference/Reference.php',
181182
'OCP\\Collaboration\\Reference\\RenderReferenceEvent' => __DIR__ . '/../../..' . '/lib/public/Collaboration/Reference/RenderReferenceEvent.php',
182183
'OCP\\Collaboration\\Resources\\CollectionException' => __DIR__ . '/../../..' . '/lib/public/Collaboration/Resources/CollectionException.php',
183184
'OCP\\Collaboration\\Resources\\ICollection' => __DIR__ . '/../../..' . '/lib/public/Collaboration/Resources/ICollection.php',
@@ -868,7 +869,6 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
868869
'OC\\Collaboration\\Reference\\File\\FileReferenceEventListener' => __DIR__ . '/../../..' . '/lib/private/Collaboration/Reference/File/FileReferenceEventListener.php',
869870
'OC\\Collaboration\\Reference\\File\\FileReferenceProvider' => __DIR__ . '/../../..' . '/lib/private/Collaboration/Reference/File/FileReferenceProvider.php',
870871
'OC\\Collaboration\\Reference\\LinkReferenceProvider' => __DIR__ . '/../../..' . '/lib/private/Collaboration/Reference/LinkReferenceProvider.php',
871-
'OC\\Collaboration\\Reference\\Reference' => __DIR__ . '/../../..' . '/lib/private/Collaboration/Reference/Reference.php',
872872
'OC\\Collaboration\\Reference\\ReferenceManager' => __DIR__ . '/../../..' . '/lib/private/Collaboration/Reference/ReferenceManager.php',
873873
'OC\\Collaboration\\Resources\\Collection' => __DIR__ . '/../../..' . '/lib/private/Collaboration/Resources/Collection.php',
874874
'OC\\Collaboration\\Resources\\Listener' => __DIR__ . '/../../..' . '/lib/private/Collaboration/Resources/Listener.php',

lib/private/Collaboration/Reference/File/FileReferenceProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@
2424

2525
namespace OC\Collaboration\Reference\File;
2626

27-
use OC\Collaboration\Reference\Reference;
2827
use OC\User\NoUserException;
2928
use OCP\Collaboration\Reference\IReference;
3029
use OCP\Collaboration\Reference\IReferenceProvider;
30+
use OCP\Collaboration\Reference\Reference;
3131
use OCP\Files\InvalidPathException;
3232
use OCP\Files\IRootFolder;
3333
use OCP\Files\Node;

lib/private/Collaboration/Reference/LinkReferenceProvider.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
use OC\SystemConfig;
3333
use OCP\Collaboration\Reference\IReference;
3434
use OCP\Collaboration\Reference\IReferenceProvider;
35+
use OCP\Collaboration\Reference\Reference;
3536
use OCP\Files\AppData\IAppDataFactory;
3637
use OCP\Files\NotFoundException;
3738
use OCP\Http\Client\IClientService;

lib/private/Collaboration/Reference/ReferenceManager.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
use OCP\Collaboration\Reference\IReference;
3030
use OCP\Collaboration\Reference\IReferenceManager;
3131
use OCP\Collaboration\Reference\IReferenceProvider;
32+
use OCP\Collaboration\Reference\Reference;
3233
use OCP\ICache;
3334
use OCP\ICacheFactory;
3435
use OCP\IURLGenerator;

lib/private/Collaboration/Reference/Reference.php renamed to lib/public/Collaboration/Reference/Reference.php

Lines changed: 98 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,99 +23,171 @@
2323
* along with this program. If not, see <http://www.gnu.org/licenses/>.
2424
*/
2525

26-
namespace OC\Collaboration\Reference;
27-
28-
use OCP\Collaboration\Reference\IReference;
26+
namespace OCP\Collaboration\Reference;
2927

28+
/**
29+
* @since 25.0.0
30+
*/
3031
class Reference implements IReference {
31-
private string $reference;
32+
protected string $reference;
3233

33-
private bool $accessible = true;
34+
protected bool $accessible = true;
3435

35-
private ?string $title = null;
36-
private ?string $description = null;
37-
private ?string $imageUrl = null;
38-
private ?string $contentType = null;
39-
private ?string $url = null;
36+
protected ?string $title = null;
37+
protected ?string $description = null;
38+
protected ?string $imageUrl = null;
39+
protected ?string $contentType = null;
40+
protected ?string $url = null;
4041

41-
private ?string $richObjectType = null;
42-
private ?array $richObject = null;
42+
protected ?string $richObjectType = null;
43+
protected ?array $richObject = null;
4344

45+
/**
46+
* @since 25.0.0
47+
*/
4448
public function __construct(string $reference) {
4549
$this->reference = $reference;
4650
}
4751

52+
/**
53+
* @inheritdoc
54+
* @since 25.0.0
55+
*/
4856
public function getId(): string {
4957
return $this->reference;
5058
}
5159

60+
/**
61+
* @inheritdoc
62+
* @since 25.0.0
63+
*/
5264
public function setAccessible(bool $accessible): void {
5365
$this->accessible = $accessible;
5466
}
5567

68+
/**
69+
* @inheritdoc
70+
* @since 25.0.0
71+
*/
5672
public function getAccessible(): bool {
5773
return $this->accessible;
5874
}
5975

76+
/**
77+
* @inheritdoc
78+
* @since 25.0.0
79+
*/
6080
public function setTitle(string $title): void {
6181
$this->title = $title;
6282
}
6383

84+
/**
85+
* @inheritdoc
86+
* @since 25.0.0
87+
*/
6488
public function getTitle(): string {
6589
return $this->title ?? $this->reference;
6690
}
6791

92+
/**
93+
* @inheritdoc
94+
* @since 25.0.0
95+
*/
6896
public function setDescription(?string $description): void {
6997
$this->description = $description;
7098
}
7199

100+
/**
101+
* @inheritdoc
102+
* @since 25.0.0
103+
*/
72104
public function getDescription(): ?string {
73105
return $this->description;
74106
}
75107

108+
/**
109+
* @inheritdoc
110+
* @since 25.0.0
111+
*/
76112
public function setImageUrl(?string $imageUrl): void {
77113
$this->imageUrl = $imageUrl;
78114
}
79115

116+
/**
117+
* @inheritdoc
118+
* @since 25.0.0
119+
*/
80120
public function getImageUrl(): ?string {
81121
return $this->imageUrl;
82122
}
83123

124+
/**
125+
* @inheritdoc
126+
* @since 25.0.0
127+
*/
84128
public function setImageContentType(?string $contentType): void {
85129
$this->contentType = $contentType;
86130
}
87131

132+
/**
133+
* @inheritdoc
134+
* @since 25.0.0
135+
*/
88136
public function getImageContentType(): ?string {
89137
return $this->contentType;
90138
}
91139

140+
/**
141+
* @inheritdoc
142+
* @since 25.0.0
143+
*/
92144
public function setUrl(?string $url): void {
93145
$this->url = $url;
94146
}
95147

148+
/**
149+
* @inheritdoc
150+
* @since 25.0.0
151+
*/
96152
public function getUrl(): ?string {
97153
return $this->url;
98154
}
99155

156+
/**
157+
* @inheritdoc
158+
* @since 25.0.0
159+
*/
100160
public function setRichObject(string $type, ?array $richObject): void {
101161
$this->richObjectType = $type;
102162
$this->richObject = $richObject;
103163
}
104164

165+
/**
166+
* @inheritdoc
167+
* @since 25.0.0
168+
*/
105169
public function getRichObjectType(): string {
106170
if ($this->richObjectType === null) {
107171
return 'open-graph';
108172
}
109173
return $this->richObjectType;
110174
}
111175

176+
/**
177+
* @inheritdoc
178+
* @since 25.0.0
179+
*/
112180
public function getRichObject(): array {
113181
if ($this->richObject === null) {
114182
return $this->getOpenGraphObject();
115183
}
116184
return $this->richObject;
117185
}
118186

187+
/**
188+
* @inheritdoc
189+
* @since 25.0.0
190+
*/
119191
public function getOpenGraphObject(): array {
120192
return [
121193
'id' => $this->getId(),
@@ -126,6 +198,11 @@ public function getOpenGraphObject(): array {
126198
];
127199
}
128200

201+
/**
202+
* @param IReference $reference
203+
* @return array
204+
* @since 25.0.0
205+
*/
129206
public static function toCache(IReference $reference): array {
130207
return [
131208
'id' => $reference->getId(),
@@ -140,6 +217,11 @@ public static function toCache(IReference $reference): array {
140217
];
141218
}
142219

220+
/**
221+
* @param array $cache
222+
* @return IReference
223+
* @since 25.0.0
224+
*/
143225
public static function fromCache(array $cache): IReference {
144226
$reference = new Reference($cache['id']);
145227
$reference->setTitle($cache['title']);
@@ -152,6 +234,10 @@ public static function fromCache(array $cache): IReference {
152234
return $reference;
153235
}
154236

237+
/**
238+
* @inheritdoc
239+
* @since 25.0.0
240+
*/
155241
public function jsonSerialize() {
156242
return [
157243
'richObjectType' => $this->getRichObjectType(),

0 commit comments

Comments
 (0)