File tree Expand file tree Collapse file tree 4 files changed +33
-14
lines changed
Expand file tree Collapse file tree 4 files changed +33
-14
lines changed Original file line number Diff line number Diff line change 2929use OCP \Share \IAttributes ;
3030use OCP \Share \IShare ;
3131use OCP \Share \IShareProvider ;
32+ use OCP \Share \IShareProviderSupportsAccept ;
3233use Psr \Log \LoggerInterface ;
3334use function str_starts_with ;
3435
3738 *
3839 * @package OC\Share20
3940 */
40- class DefaultShareProvider implements IShareProvider {
41+ class DefaultShareProvider implements IShareProvider, IShareProviderSupportsAccept {
4142 // Special share type for user modified group shares
4243 public const SHARE_TYPE_USERGROUP = 2 ;
4344
Original file line number Diff line number Diff line change 4444use OCP \Share \IProviderFactory ;
4545use OCP \Share \IShare ;
4646use OCP \Share \IShareProvider ;
47+ use OCP \Share \IShareProviderSupportsAccept ;
4748use Psr \Log \LoggerInterface ;
4849
4950/**
@@ -1004,17 +1005,17 @@ public function updateShare(IShare $share) {
10041005 * @param IShare $share
10051006 * @param string $recipientId
10061007 * @return IShare The share object
1007- * @throws \InvalidArgumentException
1008+ * @throws \InvalidArgumentException Thrown if the provider does not implement `IShareProviderSupportsAccept`
10081009 * @since 9.0.0
10091010 */
10101011 public function acceptShare (IShare $ share , string $ recipientId ): IShare {
10111012 [$ providerId ,] = $ this ->splitFullId ($ share ->getFullId ());
10121013 $ provider = $ this ->factory ->getProvider ($ providerId );
10131014
1014- if (!method_exists ($ provider , 'acceptShare ' )) {
1015- // TODO FIX ME
1015+ if (!($ provider instanceof IShareProviderSupportsAccept)) {
10161016 throw new \InvalidArgumentException ('Share provider does not support accepting ' );
10171017 }
1018+ /** @var IShareProvider&IShareProviderSupportsAccept $provider */
10181019 $ provider ->acceptShare ($ share , $ recipientId );
10191020
10201021 $ event = new ShareAcceptedEvent ($ share );
Original file line number Diff line number Diff line change @@ -44,16 +44,6 @@ public function create(\OCP\Share\IShare $share);
4444 */
4545 public function update (\OCP \Share \IShare $ share );
4646
47- /**
48- * Accept a share.
49- *
50- * @param IShare $share
51- * @param string $recipient
52- * @return IShare The share object
53- * @since 17.0.0
54- */
55- // public function acceptShare(IShare $share, string $recipient): IShare;
56-
5747 /**
5848 * Delete a share
5949 *
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ /**
4+ * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
5+ * SPDX-License-Identifier: AGPL-3.0-or-later
6+ */
7+ namespace OCP \Share ;
8+
9+ /**
10+ * Interface IShareProviderSupportsAccept
11+ *
12+ * This interface allows to define IShareProvider that can handle the `acceptShare` method,
13+ * which is available since Nextcloud 17.
14+ *
15+ * @since 30.0.0
16+ */
17+ interface IShareProviderSupportsAccept {
18+ /**
19+ * Accept a share.
20+ *
21+ * @param IShare $share
22+ * @param string $recipient
23+ * @return IShare The share object
24+ * @since 30.0.0
25+ */
26+ public function acceptShare (IShare $ share , string $ recipient ): IShare ;
27+ }
You can’t perform that action at this time.
0 commit comments