NodeTemplate
class NodeTemplate extends AbstractNodeData (View source)
A container of properties which can be used as a template for generating new nodes.
Properties
protected array | $properties | Properties of this Node |
from AbstractNodeData |
protected ContentObjectProxy | $contentObjectProxy | An optional object which is used as a content container alternative to $properties |
from AbstractNodeData |
protected string | $nodeType | The name of the node type of this node |
from AbstractNodeData |
protected DateTimeInterface | $creationDateTime | from AbstractNodeData | |
protected DateTimeInterface | $lastModificationDateTime | from AbstractNodeData | |
protected DateTimeInterface | $lastPublicationDateTime | from AbstractNodeData | |
$hidden | If this node is hidden, it is not shown in a public place |
from AbstractNodeData | |
$hiddenBeforeDateTime | If set, this node is automatically hidden before the specified date / time |
from AbstractNodeData | |
$hiddenAfterDateTime | If set, this node is automatically hidden after the specified date / time |
from AbstractNodeData | |
$hiddenInIndex | If this node should be hidden in indexes, such as a website navigation |
from AbstractNodeData | |
protected string[] | $accessRoles | List of role names which are required to access this node at all |
from AbstractNodeData |
protected NodeDataRepository | $nodeDataRepository | from AbstractNodeData | |
protected PersistenceManagerInterface | $persistenceManager | from AbstractNodeData | |
protected NodeTypeManager | $nodeTypeManager | from AbstractNodeData | |
protected string | $identifier | The UUID to use for the new node. Use with care. |
|
protected string | $name | The node name which acts as a path segment for its node path |
Methods
Make sure the properties are always an array.
Sets the specified property.
Checks if a property value contains an entity and persists it.
If this node has a property with the given name.
Sets a content object for this node.
Sets the date and time when this node becomes potentially visible.
Returns the date and time before which this node will be automatically hidden.
Sets the date and time when this node should be automatically hidden
Returns the date and time after which this node will be automatically hidden.
Sets if this node should be hidden in indexes, such as a site navigation.
Sets the roles which are required to access this node
By default this method does not do anything.
A NodeTemplate is not stored in any workspace, thus this method returns NULL.
Allows to set a UUID to use for the node that will be created from this NodeTemplate. Use with care, usually identifier generation should be left to the ContentRepository.
Returns the UUID set in this NodeTemplate.
Set the name to $newName
Get the name of this node template.
Details
__construct()
Constructs this node data container
void
ensurePropertiesIsNeverNull()
Make sure the properties are always an array.
If the JSON in the DB is corrupted, decoding it can fail, leading to a null value. This may lead to errors later, when the value is used with functions that expect an array.
void
setProperty(string $propertyName, mixed $value)
Sets the specified property.
If the node has a content object attached, the property will be set there if it is settable.
protected
persistRelatedEntities(mixed $value)
Checks if a property value contains an entity and persists it.
bool
hasProperty(string $propertyName)
If this node has a property with the given name.
If the node has a content object attached, the property will be checked there.
mixed
getProperty(string $propertyName)
Returns the specified property.
If the node has a content object attached, the property will be fetched there if it is gettable.
void
removeProperty(string $propertyName)
Removes the specified property.
If the node has a content object attached, the property will not be removed on that object if it exists.
array
getProperties()
Returns all properties of this node.
If the node has a content object attached, the properties will be fetched there.
array
getPropertyNames()
Returns the names of all properties of this node.
void
setContentObject(object $contentObject)
Sets a content object for this node.
object
getContentObject()
Returns the content object of this node (if any).
void
unsetContentObject()
Unsets the content object of this node.
void
setNodeType(NodeType $nodeType)
Sets the node type of this node.
NodeType
getNodeType()
Returns the node type of this node.
DateTime
getCreationDateTime()
No description
DateTime
getLastModificationDateTime()
No description
DateTimeInterface
getLastPublicationDateTime()
No description
void
setLastPublicationDateTime(DateTimeInterface $lastPublicationDateTime = null)
No description
void
setHidden(bool $hidden)
Sets the "hidden" flag for this node.
bool
isHidden()
Returns the current state of the hidden flag
void
setHiddenBeforeDateTime(DateTimeInterface $dateTime = null)
Sets the date and time when this node becomes potentially visible.
DateTimeInterface
getHiddenBeforeDateTime()
Returns the date and time before which this node will be automatically hidden.
void
setHiddenAfterDateTime(DateTimeInterface $dateTime = null)
Sets the date and time when this node should be automatically hidden
DateTimeInterface
getHiddenAfterDateTime()
Returns the date and time after which this node will be automatically hidden.
void
setHiddenInIndex(bool $hidden)
Sets if this node should be hidden in indexes, such as a site navigation.
bool
isHiddenInIndex()
If this node should be hidden in indexes
void
setAccessRoles(array $accessRoles)
Sets the roles which are required to access this node
array
getAccessRoles()
Returns the names of defined access roles
protected void
addOrUpdate()
By default this method does not do anything.
For persisted nodes (PersistedNodeInterface) this updates the node in the node repository, for new nodes this method will add the respective node to the repository.
protected void
updateContentObject(object $contentObject)
By default this method does not do anything.
For persisted nodes (PersistedNodeInterface) this updates the content object via the PersistenceManager
Workspace
getWorkspace()
A NodeTemplate is not stored in any workspace, thus this method returns NULL.
void
setIdentifier(string $identifier)
Allows to set a UUID to use for the node that will be created from this NodeTemplate. Use with care, usually identifier generation should be left to the ContentRepository.
string
getIdentifier()
Returns the UUID set in this NodeTemplate.
void
setName(string $newName)
Set the name to $newName
string
getName()
Get the name of this node template.
If a name has been set using setName(), it is returned. If not, but the template has a (non-empty) title property, this property is used to generate a valid name. As a last resort a random name is returned (in the form "name-XXXXX").