Skip to content

Commit 9a6bb85

Browse files
Support versions
1 parent 2c233c9 commit 9a6bb85

File tree

4 files changed

+87
-0
lines changed

4 files changed

+87
-0
lines changed

src/Kql/Interceptors/Cms/Model.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ protected function allowedMethodsForModels()
7676
'permalink',
7777
'previewUrl',
7878
'url',
79+
'version'
7980
];
8081
}
8182

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
namespace Kirby\Kql\Interceptors\Content;
4+
5+
use Kirby\Kql\Interceptor;
6+
7+
class Lock extends Interceptor
8+
{
9+
public const CLASS_ALIAS = 'lock';
10+
11+
public function allowedMethods(): array
12+
{
13+
return [
14+
'isActive',
15+
'isLocked',
16+
'modified',
17+
'toArray',
18+
'user',
19+
];
20+
}
21+
22+
public function toArray(): array
23+
{
24+
return $this->object->toArray();
25+
}
26+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
namespace Kirby\Kql\Interceptors\Content;
4+
5+
use Kirby\Kql\Interceptor;
6+
7+
class Version extends Interceptor
8+
{
9+
public const CLASS_ALIAS = 'version';
10+
11+
protected $toArray = [
12+
'content',
13+
'id',
14+
'exists',
15+
'isLatest',
16+
'lock',
17+
'modified',
18+
];
19+
20+
public function allowedMethods(): array
21+
{
22+
return [
23+
'content',
24+
'id',
25+
'exists',
26+
'isLatest',
27+
'isLocked',
28+
'lock',
29+
'modified',
30+
'read',
31+
];
32+
}
33+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
namespace Kirby\Kql\Interceptors\Content;
4+
5+
use Kirby\Kql\Interceptor;
6+
7+
class VersionId extends Interceptor
8+
{
9+
public const CLASS_ALIAS = 'versionId';
10+
11+
protected $toArray = [
12+
'value',
13+
];
14+
15+
public function allowedMethods(): array
16+
{
17+
return [
18+
'is',
19+
'value'
20+
];
21+
}
22+
23+
public function toResponse()
24+
{
25+
return $this->object->value();
26+
}
27+
}

0 commit comments

Comments
 (0)