NodeType
class NodeType (View source)
A Node Type
Although methods contained in this class belong to the public API, you should not need to deal with creating or managing node types manually. New node types should be defined in a NodeTypes.yaml file.
Properties
protected string | $name | Name of this node type. Example: "ContentRepository:Folder" |
|
protected array | $localConfiguration | Configuration for this node type, can be an arbitrarily nested array. Does not include inherited configuration. |
|
protected array | $fullConfiguration | Full configuration for this node type, can be an arbitrarily nested array. Includes any inherited configuration. |
|
protected bool | $abstract | Is this node type marked abstract |
|
protected bool | $final | Is this node type marked final |
|
protected NodeType[] | $declaredSuperTypes | node types this node type directly inherits from |
|
protected ObjectManagerInterface | $objectManager | ||
protected NodeTypeManager | $nodeTypeManager | ||
protected NodeLabelGeneratorInterface | $nodeLabelGenerator | ||
protected bool | $initialized | Whether or not this node type has been initialized (e.g. if it has been postprocessed) |
Methods
Constructs this node type
Initializes this node type
Builds the full configuration by merging configuration from the supertypes into the local configuration.
Iterates through configured postprocessors and invokes them
Returns the name of this node type
Return boolean true if marked abstract
Return boolean true if marked final
Returns the direct, explicitly declared super types of this node type.
Returns whether this node type (or any parent type) is an aggregate.
If this node type or any of the direct or indirect super types has the given name.
Get the local configuration of the node type. Should only be used internally.
Get the full configuration of the node type. Should only be used internally.
Checks if the configuration of this node type contains a setting for the given $configurationPath
Returns the configuration option with the specified $configurationPath or NULL if it does not exist
Get the human-readable label of this node type
Get additional options (if specified)
Return the node label generator class for the given node
Return the array with the defined properties. The key is the property name, the value the property configuration. There are no guarantees on how the property configuration looks like.
Returns the configured type of the specified property
Return an array with the defined default values for each property, if any.
Return an array with child nodes which should be automatically created
Checks if the given NodeType is acceptable as sub-node with the configured constraints, not taking constraints of auto-created nodes into account. Thus, this method only returns the correct result if called on NON-AUTO-CREATED nodes!
Checks if the given $nodeType is allowed as a childNode of the given $childNodeName (which must be auto-created in $this NodeType).
Internal method to check whether the passed-in $nodeType is allowed by the $constraints array.
This method loops over the constraints and finds node types that the given node type inherits from. For all matched super types, their super types are traversed to find the closest super node with a constraint which is used to evaluated if the node type is allowed. It finds the closest results for true and false, and uses the distance to choose which one wins (lowest). If no result is found the node type is allowed.
This method traverses the given node type to find the first super type that matches the constraint node type.
No description
Alias for getName().
Details
__construct(string $name, array $declaredSuperTypes, array $configuration)
Constructs this node type
protected void
initialize()
Initializes this node type
protected array
buildFullConfiguration()
Builds the full configuration by merging configuration from the supertypes into the local configuration.
static protected array
getFlattenedSuperTypes(NodeType $nodeType)
Returns a flat list of super types to inherit from.
protected array
applyPostprocessing(array $fullConfiguration)
Iterates through configured postprocessors and invokes them
string
getName()
Returns the name of this node type
bool
isAbstract()
Return boolean true if marked abstract
bool
isFinal()
Return boolean true if marked final
NodeType[]
getDeclaredSuperTypes()
Returns the direct, explicitly declared super types of this node type.
Note: NULL values are skipped since they are used only internally.
bool
isAggregate()
Returns whether this node type (or any parent type) is an aggregate.
The most prominent aggregate is a Document and everything which inherits from it, like a Page.
If a node type is marked as aggregate, it means that:
- the node type can "live on its own", i.e. can be part of an external URL
- when moving this node, all node variants are also moved (across all dimensions)
- Recursive copying only happens inside this aggregate, and stops at nested aggregates.
bool
isOfType(string $nodeType)
If this node type or any of the direct or indirect super types has the given name.
array
getLocalConfiguration()
Get the local configuration of the node type. Should only be used internally.
Note: post processing is not applied to this.
array
getFullConfiguration()
Get the full configuration of the node type. Should only be used internally.
Instead, use the hasConfiguration()/getConfiguration() methods to check/retrieve single configuration values.
bool
hasConfiguration(string $configurationPath)
Checks if the configuration of this node type contains a setting for the given $configurationPath
mixed
getConfiguration(string $configurationPath)
Returns the configuration option with the specified $configurationPath or NULL if it does not exist
string
getLabel()
Get the human-readable label of this node type
array
getOptions()
Get additional options (if specified)
NodeLabelGeneratorInterface
getNodeLabelGenerator()
Return the node label generator class for the given node
array
getProperties()
Return the array with the defined properties. The key is the property name, the value the property configuration. There are no guarantees on how the property configuration looks like.
string
getPropertyType(string $propertyName)
Returns the configured type of the specified property
array
getDefaultValuesForProperties()
Return an array with the defined default values for each property, if any.
The default value is configured for each property under the "default" key.
NodeType[]
getAutoCreatedChildNodes()
Return an array with child nodes which should be automatically created
bool
hasAutoCreatedChildNode(NodeName $nodeName)
No description
NodeType|null
getTypeOfAutoCreatedChildNode(NodeName $nodeName)
No description
bool
allowsChildNodeType(NodeType $nodeType)
Checks if the given NodeType is acceptable as sub-node with the configured constraints, not taking constraints of auto-created nodes into account. Thus, this method only returns the correct result if called on NON-AUTO-CREATED nodes!
Otherwise, allowsGrandchildNodeType() needs to be called on the parent node type.
bool
allowsGrandchildNodeType(string $childNodeName, NodeType $nodeType)
Checks if the given $nodeType is allowed as a childNode of the given $childNodeName (which must be auto-created in $this NodeType).
Only allowed to be called if $childNodeName is auto-created.
protected bool
isNodeTypeAllowedByConstraints(NodeType $nodeType, array $constraints)
Internal method to check whether the passed-in $nodeType is allowed by the $constraints array.
$constraints is an associative array where the key is the Node Type Name. If the value is "true", the node type is explicitly allowed. If the value is "false", the node type is explicitly denied. If nothing is specified, the fallback "*" is used. If that one is also not specified, we DENY by default.
Super types of the given node types are also checked, so if a super type is constrained it will also take affect on the inherited node types. The closest constrained super type match is used.
protected bool
isNodeTypeAllowedByDirectConstraints(NodeType $nodeType, array $constraints)
No description
protected bool|null
isNodeTypeAllowedByInheritanceConstraints(NodeType $nodeType, array $constraints)
This method loops over the constraints and finds node types that the given node type inherits from. For all matched super types, their super types are traversed to find the closest super node with a constraint which is used to evaluated if the node type is allowed. It finds the closest results for true and false, and uses the distance to choose which one wins (lowest). If no result is found the node type is allowed.
protected int
traverseSuperTypes(NodeType $currentNodeType, string $constraintNodeTypeName, int $distance)
This method traverses the given node type to find the first super type that matches the constraint node type.
In case the hierarchy has more than one way of finding a path to the node type it's not taken into account, since the first matched is returned. This is accepted on purpose for performance reasons and due to the fact that such hierarchies should be avoided.
protected void
setFullConfiguration(array $fullConfiguration)
No description
string
__toString()
Alias for getName().