Template
in package
Compose field structures independently of instance data.
Table of Contents
Constants
- OWNED_ATTRIBUTE_NAMES : mixed = ['data-field-path', 'data-lang', 'data-name', '...
- Attribute names crudui writes on a control or a node root.
- OWNED_ATTRIBUTE_PREFIXES : mixed = ['data-crudui-', 'data-source-']
- Prefixes of attribute names crudui writes on a control or a node root.
Methods
- checkDeclaredAttributes() : void
- Reject declared attributes at $key that are not an object of permitted names to strings; names first.
- checkDesignDeclaration() : void
- Reject a wrong value type or an unknown key in one declared design: a form field or button, a list or detail specification, or a list column or detail field. Only a form field ($field) accepts attributes and wrapper.attributes, and only a group field ($layouts) accepts layout, one of $layouts.
- checked() : stdClass
- Copy a template input as JSON values, rejecting a value that is not exactly the shape compile produces: the template kind, a field list, a button object list, an optional string keyPrefix, an optional object action, an optional description of any value and no other member; each field has exactly a string name, an object spec and a field list children.
- compile() : stdClass
- Compile composed properties into a serializable ordered template.
- loader() : MemoryLoader
- Create the composition loader from explicitly supplied file objects.
- checkConditionDeclaration() : void
- Reject a condition field whose validate.conditionTree is not the literal true or judge: every value of the field is checked as a condition tree.
- checkDeclarations() : void
- Reject a wrong value type or an unknown key in one field's multiple, lang, design and behavior declarations. Only a form field ($field) accepts declared attributes.
- checkFormDeclarations() : void
- Reject a wrong root action or buttons declaration.
- checkRangeDeclaration() : void
- Reject a range field without literal bounds and a literal step whose multiple the minimum is: the slider moves from the minimum in steps.
- closed() : void
- A closed bucket rejects its first undeclared key in member order.
- conditionValue() : bool
- A string, or a condition map: a non-empty object.
- declaredAttributeName() : bool
- Whether a name is a data-* or aria-* name crudui does not write: lowercase letters, digits, "-", "_" and "." after the prefix, starting with a letter or a digit.
- fieldList() : bool
- A JSON list of field templates.
- fields() : array<string|int, mixed>
- Compile the field templates; $root is the composed root, which a group source reads.
- groupLayouts() : array<int, string>|null
- The design.layout values a group field accepts: a repeated group has no line, and a field that is not a group has no layout.
- invalid() : never
- Fail with "Invalid {key} at {path}: expected {expected}".
- isCondition() : bool
- Whether a field declares the condition type.
- scalarChild() : bool
- A child that renders one scalar value: not repeated, not a group and not a language field.
Constants
OWNED_ATTRIBUTE_NAMES
Attribute names crudui writes on a control or a node root.
private
mixed
OWNED_ATTRIBUTE_NAMES
= ['data-field-path', 'data-lang', 'data-name', 'data-rule-name', 'data-default', 'data-is-default', 'data-type', 'data-height', 'data-upload-server', 'data-fileserver', 'data-server', 'data-max-tags', 'data-keyword-min-length', 'data-delay', 'data-api-server', 'data-max-width', 'data-min-width', 'data-max-height', 'data-min-height', 'data-preview-max-width', 'data-preview-max-height', 'data-unsupported-type']
OWNED_ATTRIBUTE_PREFIXES
Prefixes of attribute names crudui writes on a control or a node root.
private
mixed
OWNED_ATTRIBUTE_PREFIXES
= ['data-crudui-', 'data-source-']
Methods
checkDeclaredAttributes()
Reject declared attributes at $key that are not an object of permitted names to strings; names first.
public
static checkDeclaredAttributes(mixed $attributes, string $key, string $path) : void
Parameters
- $attributes : mixed
- $key : string
- $path : string
checkDesignDeclaration()
Reject a wrong value type or an unknown key in one declared design: a form field or button, a list or detail specification, or a list column or detail field. Only a form field ($field) accepts attributes and wrapper.attributes, and only a group field ($layouts) accepts layout, one of $layouts.
public
static checkDesignDeclaration(mixed $design, string $path[, bool $field = false ][, array<string|int, mixed>|null $layouts = null ][, bool $condition = false ]) : void
Parameters
- $design : mixed
- $path : string
- $field : bool = false
- $layouts : array<string|int, mixed>|null = null
- $condition : bool = false
checked()
Copy a template input as JSON values, rejecting a value that is not exactly the shape compile produces: the template kind, a field list, a button object list, an optional string keyPrefix, an optional object action, an optional description of any value and no other member; each field has exactly a string name, an object spec and a field list children.
public
static checked(stdClass $template) : stdClass
Parameters
- $template : stdClass
Return values
stdClasscompile()
Compile composed properties into a serializable ordered template.
public
static compile(array<string|int, mixed>|stdClass $spec, array<string|int, mixed> $options) : stdClass
Parameters
- $spec : array<string|int, mixed>|stdClass
- $options : array<string|int, mixed>
Return values
stdClassloader()
Create the composition loader from explicitly supplied file objects.
public
static loader(array<string|int, mixed> $options) : MemoryLoader
Parameters
- $options : array<string|int, mixed>
Return values
MemoryLoadercheckConditionDeclaration()
Reject a condition field whose validate.conditionTree is not the literal true or judge: every value of the field is checked as a condition tree.
private
static checkConditionDeclaration(array<string|int, mixed> $spec, string $path) : void
Parameters
- $spec : array<string|int, mixed>
- $path : string
checkDeclarations()
Reject a wrong value type or an unknown key in one field's multiple, lang, design and behavior declarations. Only a form field ($field) accepts declared attributes.
private
static checkDeclarations(array<string|int, mixed> $spec, string $path, bool $field) : void
Parameters
- $spec : array<string|int, mixed>
- $path : string
- $field : bool
checkFormDeclarations()
Reject a wrong root action or buttons declaration.
private
static checkFormDeclarations(stdClass $spec) : void
Parameters
- $spec : stdClass
checkRangeDeclaration()
Reject a range field without literal bounds and a literal step whose multiple the minimum is: the slider moves from the minimum in steps.
private
static checkRangeDeclaration(array<string|int, mixed> $spec, string $path) : void
Parameters
- $spec : array<string|int, mixed>
- $path : string
closed()
A closed bucket rejects its first undeclared key in member order.
private
static closed(string $bucket, array<string|int, mixed> $members, array<string|int, mixed> $allowed, string $path) : void
Parameters
- $bucket : string
- $members : array<string|int, mixed>
- $allowed : array<string|int, mixed>
- $path : string
conditionValue()
A string, or a condition map: a non-empty object.
private
static conditionValue(mixed $value) : bool
Parameters
- $value : mixed
Return values
booldeclaredAttributeName()
Whether a name is a data-* or aria-* name crudui does not write: lowercase letters, digits, "-", "_" and "." after the prefix, starting with a letter or a digit.
private
static declaredAttributeName(string $name) : bool
Parameters
- $name : string
Return values
boolfieldList()
A JSON list of field templates.
private
static fieldList(mixed $fields) : bool
Parameters
- $fields : mixed
Return values
boolfields()
Compile the field templates; $root is the composed root, which a group source reads.
private
static fields(array<string|int, mixed> $properties, array<string|int, mixed> $root[, string $parent = '' ]) : array<string|int, mixed>
Parameters
- $properties : array<string|int, mixed>
- $root : array<string|int, mixed>
- $parent : string = ''
Return values
array<string|int, mixed>groupLayouts()
The design.layout values a group field accepts: a repeated group has no line, and a field that is not a group has no layout.
private
static groupLayouts(array<string|int, mixed> $spec) : array<int, string>|null
Parameters
- $spec : array<string|int, mixed>
Return values
array<int, string>|nullinvalid()
Fail with "Invalid {key} at {path}: expected {expected}".
private
static invalid(string $key, string $path, string $expected) : never
Parameters
- $key : string
- $path : string
- $expected : string
Return values
neverisCondition()
Whether a field declares the condition type.
private
static isCondition(array<string|int, mixed> $spec) : bool
Parameters
- $spec : array<string|int, mixed>
Return values
boolscalarChild()
A child that renders one scalar value: not repeated, not a group and not a language field.
private
static scalarChild(mixed $child) : bool
Parameters
- $child : mixed