1 | <?php |
||
2 | |||
3 | /** |
||
4 | * For the full copyright and license information, please view |
||
5 | * the LICENSE file that was distributed with this source code. |
||
6 | */ |
||
7 | |||
8 | declare(strict_types=1); |
||
9 | |||
10 | namespace ChampsLibres\WopiLib\Contract\Service; |
||
11 | |||
12 | use ChampsLibres\WopiLib\Contract\Entity\Document; |
||
13 | use DateTimeInterface; |
||
14 | use Psr\Http\Message\StreamInterface; |
||
15 | |||
16 | interface DocumentManagerInterface |
||
17 | { |
||
18 | /** |
||
19 | * Create a document |
||
20 | * |
||
21 | * @param array{basename: string, name: string, extension: string, content: string, size: numeric-string} $data |
||
0 ignored issues
–
show
Documentation
Bug
introduced
by
![]() |
|||
22 | */ |
||
23 | public function create(array $data): Document; |
||
24 | |||
25 | /** |
||
26 | * Delete an existing lock attached to the document. |
||
27 | */ |
||
28 | public function deleteLock(Document $document): void; |
||
29 | |||
30 | public function findByDocumentFilename(string $documentFilename): ?Document; |
||
31 | |||
32 | public function findByDocumentId(string $documentId): ?Document; |
||
33 | |||
34 | public function getBasename(Document $document): string; |
||
35 | |||
36 | public function getCreationDate(Document $document): DateTimeInterface; |
||
37 | |||
38 | public function getDocumentId(Document $document): string; |
||
39 | |||
40 | public function getLastModifiedDate(Document $document): DateTimeInterface; |
||
41 | |||
42 | public function getLock(Document $document): string; |
||
43 | |||
44 | /** |
||
45 | * Get a sha256 from the document's content. |
||
46 | * |
||
47 | * This is used for caching purpose in the client (see https://learn.microsoft.com/en-us/microsoft-365/cloud-storage-partner-program/rest/files/checkfileinfo/checkfileinfo-other#sha256) |
||
48 | * |
||
49 | * @param Document $document |
||
50 | * @return string |
||
51 | */ |
||
52 | public function getSha256(Document $document): string; |
||
53 | |||
54 | public function getSize(Document $document): int; |
||
55 | |||
56 | /** |
||
57 | * Get version for this document. |
||
58 | * |
||
59 | * Note that CollaboraOnline does not rely on this document's version for detect change, but on |
||
60 | * @link{DocumentManagerInterface::getLastModifiedTime} |
||
61 | * @param Document $document |
||
62 | * @return string |
||
63 | */ |
||
64 | public function getVersion(Document $document): string; |
||
65 | |||
66 | public function hasLock(Document $document): bool; |
||
67 | |||
68 | /** |
||
69 | * Write a lock on the document. |
||
70 | * |
||
71 | * The lock should last 30 minutes. It will be renewed by Wopi client if needed. |
||
72 | * |
||
73 | * @param Document $document |
||
74 | * @param string $lock |
||
75 | * @return void |
||
76 | */ |
||
77 | public function lock(Document $document, string $lock): void; |
||
78 | |||
79 | public function read(Document $document): StreamInterface; |
||
80 | |||
81 | public function remove(Document $document): void; |
||
82 | |||
83 | /** |
||
84 | * Write the content into the document. |
||
85 | * |
||
86 | * **Important**: any implementation should also ensure to update the version and timestamp |
||
87 | * of the Document, after writing data. |
||
88 | * |
||
89 | * @param Document $document |
||
90 | * @param array{content: string, size: int} $properties |
||
91 | * @return void |
||
92 | */ |
||
93 | public function write(Document $document, array $properties = []): void; |
||
94 | |||
95 | public function rename(Document $document, string $requestedName): void; |
||
96 | } |
||
97 |