AbstractChildNode extends AbstractNode implements ChildNodeInterface
Generic child node. Implements common methods of NodeInterface used in all Node classes.
Tags
Table of Contents
Interfaces
- ChildNodeInterface
- The created AST consists of a NodeRoot object with nested NodeObject children.
Properties
- $children : array<string, ChildNodeInterface>
- $name : string
Methods
- __clone() : void
- Dereference children on clone().
- __construct() : mixed
- __serialize() : array<string|int, mixed>
- When storing to cache, we only store FE relevant properties and skip various BE related properties which then default to class defaults when unserialized. This is done to create smaller php cache files.
- addChild() : void
- Helper methods to operate on children.
- addComment() : void
- Helper methods to attach TypoScript tokens to a node.
- appendValue() : void
- flatten() : array<string|int, mixed>
- Flatten the tree. A RootNode with a ChildNode "foo" and value "fooValue", with this ChildNode again having a ChildNode "bar" and value "barValue" becomes: [ 'foo' => 'fooValue', 'foo.bar' => 'barValue', ]
- getChildByName() : ChildNodeInterface|null
- getComments() : array<string|int, TokenStreamInterface>
- getIdentifier() : string
- getName() : string
- Helper methods for node name.
- getNextChild() : iterable<string|int, ChildNodeInterface>
- getOriginalValueTokenStream() : TokenStreamInterface|null
- getPreviousValue() : string|null
- getValue() : string|null
- hasChildren() : bool
- isValueNull() : bool
- removeChildByName() : void
- Note this does *not* choke if that child does not exist, so we can "blindly" remove without error.
- setIdentifier() : void
- An identifier for this node. Typically, a hash of some kind. This identifier is unique within the tree, by being created from the parent identifier plus the name. This identifier is used in the backend, when referencing single nodes.
- setOriginalValueTokenStream() : void
- Helper method for backend object browser to retrieve the original stream when a constant substitution happened, only set by CommentAwareAstBuilder.
- setPreviousValue() : void
- Previous value is only set by comment aware ast builder. It is used in constant editor to see if a value has been changed.
- setValue() : void
- Helper methods for value.
- sortChildren() : void
- toArray() : array<string|int, mixed>|null
- b/w compat method to turn AST into an array.
- updateName() : void
- This forces $this->name NOT to be readonly.
- serialize() : array<string|int, mixed>
Properties
$children
protected
array<string, ChildNodeInterface>
$children
= []
$name
protected
string
$name
Methods
__clone()
Dereference children on clone().
public
__clone() : void
Used with '<' operator to create a deep-copy of the tree to copy.
__construct()
public
__construct(string $name) : mixed
Parameters
- $name : string
__serialize()
When storing to cache, we only store FE relevant properties and skip various BE related properties which then default to class defaults when unserialized. This is done to create smaller php cache files.
public
final __serialize() : array<string|int, mixed>
Return values
array<string|int, mixed>addChild()
Helper methods to operate on children.
public
addChild(ChildNodeInterface $node) : void
Parameters
- $node : ChildNodeInterface
addComment()
Helper methods to attach TypoScript tokens to a node.
public
addComment(TokenStreamInterface $tokenStream) : void
This is used in ext:tstemplate "Constant Editor" and "Object Browser" and handled by CommentAwareAstBuilder.
Parameters
- $tokenStream : TokenStreamInterface
appendValue()
public
appendValue(string $value) : void
Parameters
- $value : string
flatten()
Flatten the tree. A RootNode with a ChildNode "foo" and value "fooValue", with this ChildNode again having a ChildNode "bar" and value "barValue" becomes: [ 'foo' => 'fooValue', 'foo.bar' => 'barValue', ]
public
flatten([string $prefix = '' ]) : array<string|int, mixed>
Flattening a TypoScript tree is especially used for constants to quickly look up constants when parsing setup node value streams that use T_CONSTANT tokens.
Parameters
- $prefix : string = ''
Return values
array<string|int, mixed>getChildByName()
public
getChildByName(string $name) : ChildNodeInterface|null
Parameters
- $name : string
Return values
ChildNodeInterface|nullgetComments()
public
getComments() : array<string|int, TokenStreamInterface>
Return values
array<string|int, TokenStreamInterface>getIdentifier()
public
getIdentifier() : string
Return values
stringgetName()
Helper methods for node name.
public
getName() : string
Return values
stringgetNextChild()
public
getNextChild() : iterable<string|int, ChildNodeInterface>
Return values
iterable<string|int, ChildNodeInterface>getOriginalValueTokenStream()
public
getOriginalValueTokenStream() : TokenStreamInterface|null
Return values
TokenStreamInterface|nullgetPreviousValue()
public
getPreviousValue() : string|null
Return values
string|nullgetValue()
public
getValue() : string|null
Return values
string|nullhasChildren()
public
hasChildren() : bool
Return values
boolisValueNull()
public
isValueNull() : bool
Return values
boolremoveChildByName()
Note this does *not* choke if that child does not exist, so we can "blindly" remove without error.
public
removeChildByName(string $name) : void
Parameters
- $name : string
setIdentifier()
An identifier for this node. Typically, a hash of some kind. This identifier is unique within the tree, by being created from the parent identifier plus the name. This identifier is used in the backend, when referencing single nodes.
public
setIdentifier(string $identifier) : void
Calculating identifiers is initiated by calling setIdentifier() on RootNode, which will recurse the tree. Call this on the final tree, after AST calculation finished, so AST building itself does not need to fiddle with identifier updates when for instance tree parts are cloned using '<' operator. Note this value is skipped when persisting to caches since it's a Backend related thing that does not use cached context: When retrieving nodes from cache (e.g. in Frontend), the identifier is null and calling the getter will throw an exception.
Parameters
- $identifier : string
setOriginalValueTokenStream()
Helper method for backend object browser to retrieve the original stream when a constant substitution happened, only set by CommentAwareAstBuilder.
public
setOriginalValueTokenStream(TokenStreamInterface|null $tokenStream) : void
Parameters
- $tokenStream : TokenStreamInterface|null
setPreviousValue()
Previous value is only set by comment aware ast builder. It is used in constant editor to see if a value has been changed.
public
setPreviousValue(string|null $value) : void
Parameters
- $value : string|null
setValue()
Helper methods for value.
public
setValue(string|null $value) : void
Parameters
- $value : string|null
sortChildren()
public
sortChildren() : void
toArray()
b/w compat method to turn AST into an array.
public
toArray() : array<string|int, mixed>|null
Note we're NOT using magic __toArray() here to avoid calling array-cast of AST by accident: toArray() should be called explicitly if needed, which makes it much easier to drop this b/w compat method when we later want to drop that layer.
Note RootNode always returns an array, while ObjectNode's may return null.
Return values
array<string|int, mixed>|nullupdateName()
This forces $this->name NOT to be readonly.
public
updateName(string $name) : void
Used with '<' operator on tree root to copy: foo = value bar < foo The 'foo' object node is copied, but added to AST as name 'bar'
Parameters
- $name : string
serialize()
protected
serialize() : array<string|int, mixed>