Initial commit
This commit is contained in:
commit
08a8a71c55
631 changed files with 139902 additions and 0 deletions
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue