Skip to content

Commit

Permalink
fix(OCM): Move JsonSerializable to the interface because consumers re…
Browse files Browse the repository at this point in the history
…ly on the function

Signed-off-by: Joas Schilling <coding@schilljs.com>
  • Loading branch information
nickvergessen committed Oct 12, 2023
1 parent 506a1f3 commit f841b31
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 7 deletions.
3 changes: 1 addition & 2 deletions lib/private/OCM/Model/OCMProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

namespace OC\OCM\Model;

use JsonSerializable;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\OCM\Events\BeforeResourceTypesGetEvent;
use OCP\OCM\Exceptions\OCMArgumentException;
Expand All @@ -37,7 +36,7 @@
/**
* @since 28.0.0
*/
class OCMProvider implements IOCMProvider, JsonSerializable {
class OCMProvider implements IOCMProvider {
private bool $enabled = false;
private string $apiVersion = '';
private string $endPoint = '';
Expand Down
4 changes: 1 addition & 3 deletions lib/private/OCM/Model/OCMResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,12 @@

namespace OC\OCM\Model;

use JsonSerializable;
use OCP\OCM\IOCMResource;

/**
* @since 28.0.0
*/
class OCMResource implements IOCMResource, JsonSerializable {
class OCMResource implements IOCMResource {
private string $name = '';
/** @var string[] */
private array $shareTypes = [];
Expand Down Expand Up @@ -108,7 +107,6 @@ public function import(array $data): self {
}

/**
*
* @return array{
* name: string,
* shareTypes: string[],
Expand Down
18 changes: 17 additions & 1 deletion lib/public/OCM/IOCMProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

namespace OCP\OCM;

use JsonSerializable;
use OCP\OCM\Exceptions\OCMArgumentException;
use OCP\OCM\Exceptions\OCMProviderException;

Expand All @@ -34,7 +35,7 @@
* @link https://github.com/cs3org/OCM-API/
* @since 28.0.0
*/
interface IOCMProvider {
interface IOCMProvider extends JsonSerializable {
/**
* enable OCM
*
Expand Down Expand Up @@ -146,4 +147,19 @@ public function extractProtocolEntry(string $resourceName, string $protocol): st
* @since 28.0.0
*/
public function import(array $data): self;

/**
* @return array{
* enabled: bool,
* apiVersion: string,
* endPoint: string,
* resourceTypes: array{
* name: string,
* shareTypes: string[],
* protocols: array<string, string>
* }[]
* }
* @since 28.0.0
*/
public function jsonSerialize(): array;
}
14 changes: 13 additions & 1 deletion lib/public/OCM/IOCMResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,15 @@

namespace OCP\OCM;

use JsonSerializable;

/**
* Model based on the Open Cloud Mesh Discovery API
*
* @link https://github.com/cs3org/OCM-API/
* @since 28.0.0
*/
interface IOCMResource {
interface IOCMResource extends JsonSerializable {
/**
* set name of the resource
*
Expand Down Expand Up @@ -96,4 +98,14 @@ public function getProtocols(): array;
* @since 28.0.0
*/
public function import(array $data): self;

/**
* @return array{
* name: string,
* shareTypes: string[],
* protocols: array<string, string>
* }
* @since 28.0.0
*/
public function jsonSerialize(): array;
}

0 comments on commit f841b31

Please sign in to comment.