Skip to content

Commit

Permalink
Convert the content storage handler interface to an abstract
Browse files Browse the repository at this point in the history
  • Loading branch information
bastianallgeier committed May 17, 2024
1 parent ea67992 commit 9e4c051
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
22 changes: 11 additions & 11 deletions src/Content/ContentStorageHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Kirby\Cms\ModelWithContent;

/**
* Interface for content storage handlers;
* Abstract for content storage handlers;
* note that it is so far not viable to build custom
* handlers because the CMS core relies on the filesystem
* and cannot fully benefit from this abstraction yet
Expand All @@ -19,36 +19,36 @@
* @copyright Bastian Allgeier
* @license https://getkirby.com/license
*/
interface ContentStorageHandler
abstract class ContentStorageHandler
{
public function __construct(ModelWithContent $model);
abstract public function __construct(ModelWithContent $model);

/**
* Creates a new version
*
* @param array<string, string> $fields Content fields
*/
public function create(VersionId $versionId, Language $language, array $fields): void;
abstract public function create(VersionId $versionId, Language $language, array $fields): void;

/**
* Deletes an existing version in an idempotent way if it was already deleted
*/
public function delete(VersionId $versionId, Language $language): void;
abstract public function delete(VersionId $versionId, Language $language): void;

/**
* Checks if a version exists
*/
public function exists(VersionId $versionId, Language $language): bool;
abstract public function exists(VersionId $versionId, Language $language): bool;

/**
* Returns the modification timestamp of a version if it exists
*/
public function modified(VersionId $versionId, Language $language): int|null;
abstract public function modified(VersionId $versionId, Language $language): int|null;

/**
* Moves content from one version-language combination to another
*/
public function move(
abstract public function move(
VersionId $fromVersionId,
Language $fromLanguage,
VersionId $toVersionId,
Expand All @@ -62,14 +62,14 @@ public function move(
*
* @throws \Kirby\Exception\NotFoundException If the version does not exist
*/
public function read(VersionId $versionId, Language $language): array;
abstract public function read(VersionId $versionId, Language $language): array;

/**
* Updates the modification timestamp of an existing version
*
* @throws \Kirby\Exception\NotFoundException If the version does not exist
*/
public function touch(VersionId $versionId, Language $language): void;
abstract public function touch(VersionId $versionId, Language $language): void;

/**
* Updates the content fields of an existing version
Expand All @@ -78,5 +78,5 @@ public function touch(VersionId $versionId, Language $language): void;
*
* @throws \Kirby\Exception\NotFoundException If the version does not exist
*/
public function update(VersionId $versionId, Language $language, array $fields): void;
abstract public function update(VersionId $versionId, Language $language, array $fields): void;
}
2 changes: 1 addition & 1 deletion src/Content/PlainTextContentStorageHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
* @copyright Bastian Allgeier
* @license https://getkirby.com/license
*/
class PlainTextContentStorageHandler implements ContentStorageHandler
class PlainTextContentStorageHandler extends ContentStorageHandler
{
public function __construct(protected ModelWithContent $model)
{
Expand Down

0 comments on commit 9e4c051

Please sign in to comment.