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
protected bool $hidden

If this node is hidden, it is not shown in a public place

from  AbstractNodeData
protected DateTimeInterface $hiddenBeforeDateTime

If set, this node is automatically hidden before the specified date / time

from  AbstractNodeData
protected DateTimeInterface $hiddenAfterDateTime

If set, this node is automatically hidden after the specified date / time

from  AbstractNodeData
protected bool $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

__construct()

Constructs this node data container

void
ensurePropertiesIsNeverNull()

Make sure the properties are always an array.

void
setProperty(string $propertyName, mixed $value)

Sets the specified property.

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.

mixed
getProperty(string $propertyName)

Returns the specified property.

void
removeProperty(string $propertyName)

Removes the specified property.

array
getProperties()

Returns all properties of this node.

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.

getNodeType()

Returns the node type of this node.

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.

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

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

void
addOrUpdate()

By default this method does not do anything.

void
updateContentObject(object $contentObject)

By default this method does not do anything.

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.

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.

Return Value

void

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.

Parameters

string $propertyName

Name of the property

mixed $value

Value of the property

Return Value

void

protected persistRelatedEntities(mixed $value)

Checks if a property value contains an entity and persists it.

Parameters

mixed $value

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.

Parameters

string $propertyName

Name of the property to test for

Return Value

bool

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.

Parameters

string $propertyName

Name of the property

Return Value

mixed

value of the property

Exceptions

NodeException

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.

Parameters

string $propertyName

Name of the property

Return Value

void

Exceptions

NodeException

array getProperties()

Returns all properties of this node.

If the node has a content object attached, the properties will be fetched there.

Return Value

array

Property values, indexed by their name

array getPropertyNames()

Returns the names of all properties of this node.

Return Value

array

Property names

void setContentObject(object $contentObject)

Sets a content object for this node.

Parameters

object $contentObject

The content object

Return Value

void

Exceptions

InvalidArgumentException

object getContentObject()

Returns the content object of this node (if any).

Return Value

object

The content object or NULL if none was set

void unsetContentObject()

Unsets the content object of this node.

Return Value

void

void setNodeType(NodeType $nodeType)

Sets the node type of this node.

Parameters

NodeType $nodeType

Return Value

void

NodeType getNodeType()

Returns the node type of this node.

Return Value

NodeType

Exceptions

NodeTypeNotFoundException

DateTime getCreationDateTime()

No description

Return Value

DateTime

DateTime getLastModificationDateTime()

No description

Return Value

DateTime

DateTimeInterface getLastPublicationDateTime()

No description

Return Value

DateTimeInterface

void setLastPublicationDateTime(DateTimeInterface $lastPublicationDateTime = null)

No description

Parameters

DateTimeInterface $lastPublicationDateTime

Return Value

void

void setHidden(bool $hidden)

Sets the "hidden" flag for this node.

Parameters

bool $hidden

If true, this Node will be hidden

Return Value

void

bool isHidden()

Returns the current state of the hidden flag

Return Value

bool

void setHiddenBeforeDateTime(DateTimeInterface $dateTime = null)

Sets the date and time when this node becomes potentially visible.

Parameters

DateTimeInterface $dateTime

Date before this node should be hidden

Return Value

void

DateTimeInterface getHiddenBeforeDateTime()

Returns the date and time before which this node will be automatically hidden.

Return Value

DateTimeInterface

Date before this node will be hidden or NULL if no such time was set

void setHiddenAfterDateTime(DateTimeInterface $dateTime = null)

Sets the date and time when this node should be automatically hidden

Parameters

DateTimeInterface $dateTime

Date after which this node should be hidden or NULL if no such time was set

Return Value

void

DateTimeInterface getHiddenAfterDateTime()

Returns the date and time after which this node will be automatically hidden.

Return Value

DateTimeInterface

Date after which this node will be hidden

void setHiddenInIndex(bool $hidden)

Sets if this node should be hidden in indexes, such as a site navigation.

Parameters

bool $hidden

true if it should be hidden, otherwise false

Return Value

void

bool isHiddenInIndex()

If this node should be hidden in indexes

Return Value

bool

void setAccessRoles(array $accessRoles)

Sets the roles which are required to access this node

Parameters

array $accessRoles

Return Value

void

Exceptions

InvalidArgumentException

array getAccessRoles()

Returns the names of defined access roles

Return Value

array

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.

Return Value

void

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

Parameters

object $contentObject

Return Value

void

Workspace getWorkspace()

A NodeTemplate is not stored in any workspace, thus this method returns NULL.

Return Value

Workspace

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.

Parameters

string $identifier

Return Value

void

Exceptions

InvalidArgumentException

string getIdentifier()

Returns the UUID set in this NodeTemplate.

Return Value

string

void setName(string $newName)

Set the name to $newName

Parameters

string $newName

Return Value

void

Exceptions

InvalidArgumentException

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").

Return Value

string