Initial commit
This commit is contained in:
commit
08a8a71c55
631 changed files with 139902 additions and 0 deletions
39
public/site/plugins/kql/src/Kql/Interceptors/Cms/App.php
Normal file
39
public/site/plugins/kql/src/Kql/Interceptors/Cms/App.php
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
namespace Kirby\Kql\Interceptors\Cms;
|
||||
|
||||
use Kirby\Kql\Interceptor;
|
||||
|
||||
class App extends Interceptor
|
||||
{
|
||||
public const CLASS_ALIAS = 'kirby';
|
||||
|
||||
protected $toArray = [
|
||||
'site',
|
||||
'url'
|
||||
];
|
||||
|
||||
public function allowedMethods(): array
|
||||
{
|
||||
return [
|
||||
'collection',
|
||||
'defaultLanguage',
|
||||
'detectedLanguage',
|
||||
'draft',
|
||||
'file',
|
||||
'language',
|
||||
'languageCode',
|
||||
'languages',
|
||||
'multilang',
|
||||
'page',
|
||||
'roles',
|
||||
'site',
|
||||
'translation',
|
||||
'translations',
|
||||
'url',
|
||||
'user',
|
||||
'users',
|
||||
'version'
|
||||
];
|
||||
}
|
||||
}
|
||||
34
public/site/plugins/kql/src/Kql/Interceptors/Cms/Block.php
Executable file
34
public/site/plugins/kql/src/Kql/Interceptors/Cms/Block.php
Executable file
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
namespace Kirby\Kql\Interceptors\Cms;
|
||||
|
||||
class Block extends Model
|
||||
{
|
||||
public const CLASS_ALIAS = 'block';
|
||||
|
||||
protected $toArray = [
|
||||
'content',
|
||||
'id',
|
||||
'isEmpty',
|
||||
'isHidden',
|
||||
'type'
|
||||
];
|
||||
|
||||
public function allowedMethods(): array
|
||||
{
|
||||
return array_merge(
|
||||
$this->allowedMethodsForSiblings(),
|
||||
[
|
||||
'content',
|
||||
'id',
|
||||
'isEmpty',
|
||||
'isHidden',
|
||||
'isNotEmpty',
|
||||
'toField',
|
||||
'toHtml',
|
||||
'parent',
|
||||
'type'
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
24
public/site/plugins/kql/src/Kql/Interceptors/Cms/Blocks.php
Executable file
24
public/site/plugins/kql/src/Kql/Interceptors/Cms/Blocks.php
Executable file
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
namespace Kirby\Kql\Interceptors\Cms;
|
||||
|
||||
class Blocks extends Collection
|
||||
{
|
||||
public const CLASS_ALIAS = 'blocks';
|
||||
|
||||
public function allowedMethods(): array
|
||||
{
|
||||
return array_merge(
|
||||
parent::allowedMethods(),
|
||||
[
|
||||
'excerpt',
|
||||
'toHtml'
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
public function toArray(): array
|
||||
{
|
||||
return $this->object->toArray();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,72 @@
|
|||
<?php
|
||||
|
||||
namespace Kirby\Kql\Interceptors\Cms;
|
||||
|
||||
use Kirby\Kql\Interceptor;
|
||||
|
||||
class Blueprint extends Interceptor
|
||||
{
|
||||
public const CLASS_ALIAS = 'blueprint';
|
||||
|
||||
protected $toArray = [
|
||||
'description',
|
||||
'fields',
|
||||
'isDefault',
|
||||
'name',
|
||||
'sections',
|
||||
'options',
|
||||
'tabs',
|
||||
'title',
|
||||
];
|
||||
|
||||
public function allowedMethods(): array
|
||||
{
|
||||
return [
|
||||
'description',
|
||||
'field',
|
||||
'fields',
|
||||
'isDefault',
|
||||
'name',
|
||||
'options',
|
||||
'section',
|
||||
'sections',
|
||||
'tab',
|
||||
'tabs',
|
||||
'title',
|
||||
];
|
||||
}
|
||||
|
||||
public function fields(): array
|
||||
{
|
||||
return $this->object->fields();
|
||||
}
|
||||
|
||||
public function sections(): array
|
||||
{
|
||||
return array_keys($this->object->sections());
|
||||
}
|
||||
|
||||
public function tab(string $name): ?array
|
||||
{
|
||||
if ($tab = $this->object->tab($name)) {
|
||||
foreach ($tab['columns'] as $columnIndex => $column) {
|
||||
$tab['columns'][$columnIndex]['sections'] = array_keys($column['sections']);
|
||||
}
|
||||
|
||||
return $tab;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function tabs(): array
|
||||
{
|
||||
$tabs = [];
|
||||
|
||||
foreach ($this->object->tabs() as $tab) {
|
||||
$tabs[$tab['name']] = $this->tab($tab['name']);
|
||||
}
|
||||
|
||||
return $tabs;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
<?php
|
||||
|
||||
namespace Kirby\Kql\Interceptors\Cms;
|
||||
|
||||
use Kirby\Kql\Interceptor;
|
||||
|
||||
class Collection extends Interceptor
|
||||
{
|
||||
public const CLASS_ALIAS = 'collection';
|
||||
|
||||
public function allowedMethods(): array
|
||||
{
|
||||
return [
|
||||
'chunk',
|
||||
'count',
|
||||
'filterBy',
|
||||
'find',
|
||||
'findBy',
|
||||
'findByKey',
|
||||
'first',
|
||||
'flip',
|
||||
'groupBy',
|
||||
'has',
|
||||
'isEmpty',
|
||||
'isEven',
|
||||
'isNotEmpty',
|
||||
'isOdd',
|
||||
'keys',
|
||||
'last',
|
||||
'limit',
|
||||
'next',
|
||||
'not',
|
||||
'nth',
|
||||
'offset',
|
||||
'pagination',
|
||||
'pluck',
|
||||
'prev',
|
||||
'shuffle',
|
||||
'slice',
|
||||
'sortBy',
|
||||
'without',
|
||||
];
|
||||
}
|
||||
|
||||
public function toArray(): array
|
||||
{
|
||||
return $this->object->keys();
|
||||
}
|
||||
}
|
||||
71
public/site/plugins/kql/src/Kql/Interceptors/Cms/File.php
Normal file
71
public/site/plugins/kql/src/Kql/Interceptors/Cms/File.php
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
<?php
|
||||
|
||||
namespace Kirby\Kql\Interceptors\Cms;
|
||||
|
||||
class File extends Model
|
||||
{
|
||||
public const CLASS_ALIAS = 'file';
|
||||
|
||||
protected $toArray = [
|
||||
'extension',
|
||||
'filename',
|
||||
'height',
|
||||
'id',
|
||||
'mime',
|
||||
'niceSize',
|
||||
'template',
|
||||
'type',
|
||||
'url',
|
||||
'width'
|
||||
];
|
||||
|
||||
public function allowedMethods(): array
|
||||
{
|
||||
return array_merge(
|
||||
$this->allowedMethodsForModels(),
|
||||
$this->allowedMethodsForParents(),
|
||||
$this->allowedMethodsForSiblings(),
|
||||
[
|
||||
'blur',
|
||||
'bw',
|
||||
'crop',
|
||||
'dataUri',
|
||||
'dimensions',
|
||||
'exif',
|
||||
'extension',
|
||||
'filename',
|
||||
'files',
|
||||
'grayscale',
|
||||
'greyscale',
|
||||
'height',
|
||||
'html',
|
||||
'isPortrait',
|
||||
'isLandscape',
|
||||
'isSquare',
|
||||
'mime',
|
||||
'name',
|
||||
'niceSize',
|
||||
'orientation',
|
||||
'ratio',
|
||||
'resize',
|
||||
'size',
|
||||
'srcset',
|
||||
'template',
|
||||
'templateSiblings',
|
||||
'thumb',
|
||||
'type',
|
||||
'width'
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
public function dimensions(): array
|
||||
{
|
||||
return $this->object->dimensions()->toArray();
|
||||
}
|
||||
|
||||
public function exif(): array
|
||||
{
|
||||
return $this->object->exif()->toArray();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace Kirby\Kql\Interceptors\Cms;
|
||||
|
||||
class FileVersion extends File
|
||||
{
|
||||
public const CLASS_ALIAS = 'file';
|
||||
}
|
||||
18
public/site/plugins/kql/src/Kql/Interceptors/Cms/Files.php
Normal file
18
public/site/plugins/kql/src/Kql/Interceptors/Cms/Files.php
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
|
||||
namespace Kirby\Kql\Interceptors\Cms;
|
||||
|
||||
class Files extends Collection
|
||||
{
|
||||
public const CLASS_ALIAS = 'files';
|
||||
|
||||
public function allowedMethods(): array
|
||||
{
|
||||
return array_merge(
|
||||
parent::allowedMethods(),
|
||||
[
|
||||
'template'
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
30
public/site/plugins/kql/src/Kql/Interceptors/Cms/Layout.php
Executable file
30
public/site/plugins/kql/src/Kql/Interceptors/Cms/Layout.php
Executable file
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
namespace Kirby\Kql\Interceptors\Cms;
|
||||
|
||||
class Layout extends Model
|
||||
{
|
||||
public const CLASS_ALIAS = 'layout';
|
||||
|
||||
protected $toArray = [
|
||||
'attrs',
|
||||
'columns',
|
||||
'id',
|
||||
'isEmpty',
|
||||
];
|
||||
|
||||
public function allowedMethods(): array
|
||||
{
|
||||
return array_merge(
|
||||
$this->allowedMethodsForSiblings(),
|
||||
[
|
||||
'attrs',
|
||||
'columns',
|
||||
'id',
|
||||
'isEmpty',
|
||||
'isNotEmpty',
|
||||
'parent'
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
30
public/site/plugins/kql/src/Kql/Interceptors/Cms/LayoutColumn.php
Executable file
30
public/site/plugins/kql/src/Kql/Interceptors/Cms/LayoutColumn.php
Executable file
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
namespace Kirby\Kql\Interceptors\Cms;
|
||||
|
||||
class LayoutColumn extends Model
|
||||
{
|
||||
public const CLASS_ALIAS = 'layoutColumn';
|
||||
|
||||
protected $toArray = [
|
||||
'blocks',
|
||||
'id',
|
||||
'isEmpty',
|
||||
'width',
|
||||
];
|
||||
|
||||
public function allowedMethods(): array
|
||||
{
|
||||
return array_merge(
|
||||
$this->allowedMethodsForSiblings(),
|
||||
[
|
||||
'blocks',
|
||||
'id',
|
||||
'isEmpty',
|
||||
'isNotEmpty',
|
||||
'span',
|
||||
'width'
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
13
public/site/plugins/kql/src/Kql/Interceptors/Cms/LayoutColumns.php
Executable file
13
public/site/plugins/kql/src/Kql/Interceptors/Cms/LayoutColumns.php
Executable file
|
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
|
||||
namespace Kirby\Kql\Interceptors\Cms;
|
||||
|
||||
class LayoutColumns extends Collection
|
||||
{
|
||||
public const CLASS_ALIAS = 'layoutColumns';
|
||||
|
||||
public function toArray(): array
|
||||
{
|
||||
return $this->object->toArray();
|
||||
}
|
||||
}
|
||||
13
public/site/plugins/kql/src/Kql/Interceptors/Cms/Layouts.php
Executable file
13
public/site/plugins/kql/src/Kql/Interceptors/Cms/Layouts.php
Executable file
|
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
|
||||
namespace Kirby\Kql\Interceptors\Cms;
|
||||
|
||||
class Layouts extends Collection
|
||||
{
|
||||
public const CLASS_ALIAS = 'layouts';
|
||||
|
||||
public function toArray(): array
|
||||
{
|
||||
return $this->object->toArray();
|
||||
}
|
||||
}
|
||||
113
public/site/plugins/kql/src/Kql/Interceptors/Cms/Model.php
Normal file
113
public/site/plugins/kql/src/Kql/Interceptors/Cms/Model.php
Normal file
|
|
@ -0,0 +1,113 @@
|
|||
<?php
|
||||
|
||||
namespace Kirby\Kql\Interceptors\Cms;
|
||||
|
||||
use Kirby\Kql\Interceptor;
|
||||
|
||||
class Model extends Interceptor
|
||||
{
|
||||
public const CLASS_ALIAS = 'model';
|
||||
|
||||
public function __call($method, array $args = [])
|
||||
{
|
||||
if ($this->isAllowedMethod($method) === true) {
|
||||
return $this->object->$method(...$args);
|
||||
}
|
||||
|
||||
if (method_exists($this->object, $method) === false) {
|
||||
return $this->object->content()->get($method);
|
||||
}
|
||||
|
||||
$this->forbiddenMethod($method);
|
||||
}
|
||||
|
||||
protected function allowedMethodsForChildren()
|
||||
{
|
||||
return [
|
||||
'children',
|
||||
'childrenAndDrafts',
|
||||
'draft',
|
||||
'drafts',
|
||||
'find',
|
||||
'findPageOrDraft',
|
||||
'grandChildren',
|
||||
'hasChildren',
|
||||
'hasDrafts',
|
||||
'hasListedChildren',
|
||||
'hasUnlistedChildren',
|
||||
'index',
|
||||
'search',
|
||||
];
|
||||
}
|
||||
|
||||
protected function allowedMethodsForFiles()
|
||||
{
|
||||
return [
|
||||
'audio',
|
||||
'code',
|
||||
'documents',
|
||||
'file',
|
||||
'files',
|
||||
'hasAudio',
|
||||
'hasCode',
|
||||
'hasDocuments',
|
||||
'hasFiles',
|
||||
'hasImages',
|
||||
'hasVideos',
|
||||
'image',
|
||||
'images',
|
||||
'videos'
|
||||
];
|
||||
}
|
||||
|
||||
protected function allowedMethodsForModels()
|
||||
{
|
||||
return [
|
||||
'apiUrl',
|
||||
'blueprint',
|
||||
'content',
|
||||
'dragText',
|
||||
'exists',
|
||||
'id',
|
||||
'mediaUrl',
|
||||
'modified',
|
||||
'permissions',
|
||||
'panel',
|
||||
'permalink',
|
||||
'previewUrl',
|
||||
'url',
|
||||
];
|
||||
}
|
||||
|
||||
protected function allowedMethodsForSiblings()
|
||||
{
|
||||
return [
|
||||
'indexOf',
|
||||
'next',
|
||||
'nextAll',
|
||||
'prev',
|
||||
'prevAll',
|
||||
'siblings',
|
||||
'hasNext',
|
||||
'hasPrev',
|
||||
'isFirst',
|
||||
'isLast',
|
||||
'isNth'
|
||||
];
|
||||
}
|
||||
|
||||
protected function allowedMethodsForParents()
|
||||
{
|
||||
return [
|
||||
'parent',
|
||||
'parentId',
|
||||
'parentModel',
|
||||
'site',
|
||||
];
|
||||
}
|
||||
|
||||
public function uuid(): string
|
||||
{
|
||||
return $this->object->uuid()->toString();
|
||||
}
|
||||
}
|
||||
68
public/site/plugins/kql/src/Kql/Interceptors/Cms/Page.php
Normal file
68
public/site/plugins/kql/src/Kql/Interceptors/Cms/Page.php
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
<?php
|
||||
|
||||
namespace Kirby\Kql\Interceptors\Cms;
|
||||
|
||||
class Page extends Model
|
||||
{
|
||||
public const CLASS_ALIAS = 'page';
|
||||
|
||||
protected $toArray = [
|
||||
'children',
|
||||
'content',
|
||||
'drafts',
|
||||
'files',
|
||||
'id',
|
||||
'intendedTemplate',
|
||||
'isHomePage',
|
||||
'isErrorPage',
|
||||
'num',
|
||||
'template',
|
||||
'title',
|
||||
'slug',
|
||||
'status',
|
||||
'uid',
|
||||
'url'
|
||||
];
|
||||
|
||||
public function allowedMethods(): array
|
||||
{
|
||||
return array_merge(
|
||||
$this->allowedMethodsForChildren(),
|
||||
$this->allowedMethodsForFiles(),
|
||||
$this->allowedMethodsForModels(),
|
||||
$this->allowedMethodsForParents(),
|
||||
$this->allowedMethodsForSiblings(),
|
||||
[
|
||||
'blueprints',
|
||||
'depth',
|
||||
'hasTemplate',
|
||||
'intendedTemplate',
|
||||
'isDraft',
|
||||
'isErrorPage',
|
||||
'isHomePage',
|
||||
'isHomeOrErrorPage',
|
||||
'isListed',
|
||||
'isReadable',
|
||||
'isSortable',
|
||||
'isUnlisted',
|
||||
'num',
|
||||
'slug',
|
||||
'status',
|
||||
'template',
|
||||
'title',
|
||||
'uid',
|
||||
'uri',
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
public function intendedTemplate(): string
|
||||
{
|
||||
return $this->object->intendedTemplate()->name();
|
||||
}
|
||||
|
||||
public function template(): string
|
||||
{
|
||||
return $this->object->template()->name();
|
||||
}
|
||||
}
|
||||
34
public/site/plugins/kql/src/Kql/Interceptors/Cms/Pages.php
Normal file
34
public/site/plugins/kql/src/Kql/Interceptors/Cms/Pages.php
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
namespace Kirby\Kql\Interceptors\Cms;
|
||||
|
||||
class Pages extends Collection
|
||||
{
|
||||
public const CLASS_ALIAS = 'pages';
|
||||
|
||||
public function allowedMethods(): array
|
||||
{
|
||||
return array_merge(
|
||||
parent::allowedMethods(),
|
||||
[
|
||||
'audio',
|
||||
'children',
|
||||
'code',
|
||||
'documents',
|
||||
'drafts',
|
||||
'files',
|
||||
'findByUri',
|
||||
'images',
|
||||
'index',
|
||||
'listed',
|
||||
'notTemplate',
|
||||
'nums',
|
||||
'published',
|
||||
'search',
|
||||
'template',
|
||||
'unlisted',
|
||||
'videos',
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
33
public/site/plugins/kql/src/Kql/Interceptors/Cms/Role.php
Normal file
33
public/site/plugins/kql/src/Kql/Interceptors/Cms/Role.php
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
|
||||
namespace Kirby\Kql\Interceptors\Cms;
|
||||
|
||||
use Kirby\Kql\Interceptor;
|
||||
|
||||
class Role extends Interceptor
|
||||
{
|
||||
public const CLASS_ALIAS = 'role';
|
||||
|
||||
protected $toArray = [
|
||||
'description',
|
||||
'id',
|
||||
'name',
|
||||
'title',
|
||||
];
|
||||
|
||||
public function allowedMethods(): array
|
||||
{
|
||||
return [
|
||||
'description',
|
||||
'id',
|
||||
'name',
|
||||
'permissions',
|
||||
'title'
|
||||
];
|
||||
}
|
||||
|
||||
public function permissions(): array
|
||||
{
|
||||
return $this->object->permissions()->toArray();
|
||||
}
|
||||
}
|
||||
36
public/site/plugins/kql/src/Kql/Interceptors/Cms/Site.php
Normal file
36
public/site/plugins/kql/src/Kql/Interceptors/Cms/Site.php
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
|
||||
namespace Kirby\Kql\Interceptors\Cms;
|
||||
|
||||
class Site extends Model
|
||||
{
|
||||
public const CLASS_ALIAS = 'site';
|
||||
|
||||
protected $toArray = [
|
||||
'children',
|
||||
'drafts',
|
||||
'files',
|
||||
'title',
|
||||
'url',
|
||||
];
|
||||
|
||||
public function allowedMethods(): array
|
||||
{
|
||||
return array_merge(
|
||||
$this->allowedMethodsForChildren(),
|
||||
$this->allowedMethodsForFiles(),
|
||||
$this->allowedMethodsForModels(),
|
||||
[
|
||||
'blueprints',
|
||||
'breadcrumb',
|
||||
'errorPage',
|
||||
'errorPageId',
|
||||
'homePage',
|
||||
'homePageId',
|
||||
'page',
|
||||
'pages',
|
||||
'title',
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
|
||||
namespace Kirby\Kql\Interceptors\Cms;
|
||||
|
||||
class Structure extends Collection
|
||||
{
|
||||
public const CLASS_ALIAS = 'structure';
|
||||
|
||||
public function toArray(): array
|
||||
{
|
||||
return $this->object->toArray();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
|
||||
namespace Kirby\Kql\Interceptors\Cms;
|
||||
|
||||
class StructureObject extends Model
|
||||
{
|
||||
public const CLASS_ALIAS = 'structureItem';
|
||||
|
||||
public function allowedMethods(): array
|
||||
{
|
||||
return array_merge(
|
||||
$this->allowedMethodsForSiblings(),
|
||||
[
|
||||
'content',
|
||||
'id',
|
||||
'parent',
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
35
public/site/plugins/kql/src/Kql/Interceptors/Cms/Translation.php
Executable file
35
public/site/plugins/kql/src/Kql/Interceptors/Cms/Translation.php
Executable file
|
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
|
||||
namespace Kirby\Kql\Interceptors\Cms;
|
||||
|
||||
use Kirby\Kql\Interceptor;
|
||||
|
||||
class Translation extends Interceptor
|
||||
{
|
||||
public const CLASS_ALIAS = 'translation';
|
||||
|
||||
protected $toArray = [
|
||||
'code',
|
||||
'data',
|
||||
'direction',
|
||||
'id',
|
||||
'name',
|
||||
'locale',
|
||||
'author'
|
||||
];
|
||||
|
||||
public function allowedMethods(): array
|
||||
{
|
||||
return [
|
||||
'code',
|
||||
'data',
|
||||
'dataWithFallback',
|
||||
'direction',
|
||||
'get',
|
||||
'id',
|
||||
'name',
|
||||
'locale',
|
||||
'author'
|
||||
];
|
||||
}
|
||||
}
|
||||
35
public/site/plugins/kql/src/Kql/Interceptors/Cms/User.php
Normal file
35
public/site/plugins/kql/src/Kql/Interceptors/Cms/User.php
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
|
||||
namespace Kirby\Kql\Interceptors\Cms;
|
||||
|
||||
class User extends Model
|
||||
{
|
||||
public const CLASS_ALIAS = 'user';
|
||||
|
||||
protected $toArray = [
|
||||
'id',
|
||||
'name',
|
||||
'role',
|
||||
'username'
|
||||
];
|
||||
|
||||
public function allowedMethods(): array
|
||||
{
|
||||
return array_merge(
|
||||
$this->allowedMethodsForFiles(),
|
||||
$this->allowedMethodsForModels(),
|
||||
$this->allowedMethodsForSiblings(),
|
||||
[
|
||||
'avatar',
|
||||
'email',
|
||||
'id',
|
||||
'isAdmin',
|
||||
'language',
|
||||
'modified',
|
||||
'name',
|
||||
'role',
|
||||
'username',
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
18
public/site/plugins/kql/src/Kql/Interceptors/Cms/Users.php
Normal file
18
public/site/plugins/kql/src/Kql/Interceptors/Cms/Users.php
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
|
||||
namespace Kirby\Kql\Interceptors\Cms;
|
||||
|
||||
class Users extends Collection
|
||||
{
|
||||
public const CLASS_ALIAS = 'users';
|
||||
|
||||
public function allowedMethods(): array
|
||||
{
|
||||
return array_merge(
|
||||
parent::allowedMethods(),
|
||||
[
|
||||
'role'
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
|
||||
namespace Kirby\Kql\Interceptors\Content;
|
||||
|
||||
use Kirby\Kql\Interceptor;
|
||||
|
||||
class Content extends Interceptor
|
||||
{
|
||||
public const CLASS_ALIAS = 'content';
|
||||
|
||||
public function __call($method, array $args = [])
|
||||
{
|
||||
if ($this->isAllowedMethod($method) === true) {
|
||||
return $this->object->$method(...$args);
|
||||
}
|
||||
|
||||
if (method_exists($this->object, $method) === false) {
|
||||
return $this->object->get($method);
|
||||
}
|
||||
|
||||
$this->forbiddenMethod($method);
|
||||
}
|
||||
|
||||
public function allowedMethods(): array
|
||||
{
|
||||
return [
|
||||
'data',
|
||||
'fields',
|
||||
'has',
|
||||
'get',
|
||||
'keys',
|
||||
'not',
|
||||
];
|
||||
}
|
||||
|
||||
public function toArray(): array
|
||||
{
|
||||
return $this->object->toArray();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
<?php
|
||||
|
||||
namespace Kirby\Kql\Interceptors\Content;
|
||||
|
||||
use Kirby\Kql\Interceptor;
|
||||
|
||||
class Field extends Interceptor
|
||||
{
|
||||
public const CLASS_ALIAS = 'field';
|
||||
|
||||
public function __call($method, array $args = [])
|
||||
{
|
||||
if ($this->isAllowedMethod($method) === true) {
|
||||
return $this->object->$method(...$args);
|
||||
}
|
||||
|
||||
// field methods
|
||||
$methods = array_keys($this->object::$methods);
|
||||
$method = strtolower($method);
|
||||
|
||||
if (in_array($method, $methods) === true) {
|
||||
return $this->object->$method(...$args);
|
||||
}
|
||||
|
||||
// aliases
|
||||
$aliases = array_keys($this->object::$aliases);
|
||||
$alias = strtolower($method);
|
||||
|
||||
if (in_array($alias, $aliases) === true) {
|
||||
return $this->object->$method(...$args);
|
||||
}
|
||||
|
||||
$this->forbiddenMethod($method);
|
||||
}
|
||||
|
||||
public function allowedMethods(): array
|
||||
{
|
||||
return [
|
||||
'exists',
|
||||
'isEmpty',
|
||||
'isNotEmpty',
|
||||
'key',
|
||||
'or',
|
||||
'value'
|
||||
];
|
||||
}
|
||||
|
||||
public function toResponse()
|
||||
{
|
||||
return $this->object->toString();
|
||||
}
|
||||
}
|
||||
30
public/site/plugins/kql/src/Kql/Interceptors/Panel/Model.php
Executable file
30
public/site/plugins/kql/src/Kql/Interceptors/Panel/Model.php
Executable file
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
namespace Kirby\Kql\Interceptors\Panel;
|
||||
|
||||
use Kirby\Kql\Interceptor;
|
||||
|
||||
class Model extends Interceptor
|
||||
{
|
||||
public const CLASS_ALIAS = 'panel';
|
||||
|
||||
public function allowedMethods(): array
|
||||
{
|
||||
return [
|
||||
'dragText',
|
||||
'image',
|
||||
'path',
|
||||
'url',
|
||||
];
|
||||
}
|
||||
|
||||
public function toArray(): array
|
||||
{
|
||||
return [
|
||||
'dragText' => $this->dragText(),
|
||||
'image' => $this->image(),
|
||||
'path' => $this->path(),
|
||||
'url' => $this->url(),
|
||||
];
|
||||
}
|
||||
}
|
||||
24
public/site/plugins/kql/src/Kql/Interceptors/Toolkit/Obj.php
Executable file
24
public/site/plugins/kql/src/Kql/Interceptors/Toolkit/Obj.php
Executable file
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
namespace Kirby\Kql\Interceptors\Toolkit;
|
||||
|
||||
use Kirby\Kql\Interceptor;
|
||||
|
||||
class Obj extends Interceptor
|
||||
{
|
||||
public const CLASS_ALIAS = 'obj';
|
||||
|
||||
public function allowedMethods(): array
|
||||
{
|
||||
return [
|
||||
'get',
|
||||
'toArray',
|
||||
'toJson',
|
||||
];
|
||||
}
|
||||
|
||||
public function toArray(): array
|
||||
{
|
||||
return $this->object->toArray();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue