class PublishingService extends PublishingService (View source)

The workspaces service adds some basic helper methods for getting workspaces, unpublished nodes and methods for publishing nodes or whole workspaces.

Properties

protected WorkspaceRepository $workspaceRepository from  PublishingService
protected NodeDataRepository $nodeDataRepository from  PublishingService
protected NodeFactory $nodeFactory from  PublishingService
protected ContextFactoryInterface $contextFactory from  PublishingService
protected ContentDimensionPresetSourceInterface $contentDimensionPresetSource from  PublishingService

Methods

getUnpublishedNodes(Workspace $workspace)

Returns a list of nodes contained in the given workspace which are not yet published

int
getUnpublishedNodesCount(Workspace $workspace)

Returns the number of unpublished nodes contained in the given workspace

void
publishNode(NodeInterface $node, Workspace $targetWorkspace = null)

Publishes the given node to the specified target workspace. If no workspace is specified, the base workspace is assumed.

void
publishNodes(array $nodes, Workspace $targetWorkspace = null)

Publishes the given nodes to the specified target workspace. If no workspace is specified, the source workspace's base workspace is assumed.

void
discardNode(NodeInterface $node)

Discards the given node from its workspace.

void
doDiscardNode(NodeInterface $node, array $alreadyDiscardedNodeIdentifiers = [])

Method which does the actual work of discarding, includes a protection against endless recursions and multiple discarding of the same node.

void
discardNodes(array $nodes)

Discards the given nodes.

void
discardAllNodes(Workspace $workspace)

Discards all unpublished nodes of the given workspace.

array
sortNodesForPublishing(array $nodes)

Sort an unsorted list of nodes in a publishable order

void
emitNodePublished(NodeInterface $node, Workspace $targetWorkspace = null)

Signals that a node has been published.

void
emitNodeDiscarded(NodeInterface $node)

Signals that a node has been discarded.

createContext(Workspace $workspace, array $dimensionValues, array $contextProperties = [])

Creates a new content context based on the given workspace and the NodeData object.

array
collectAllContentChildNodes(NodeInterface $parentNode, array $collectedNodes = [])

No description

Details

NodeInterface[] getUnpublishedNodes(Workspace $workspace)

Returns a list of nodes contained in the given workspace which are not yet published

Parameters

Workspace $workspace

Return Value

NodeInterface[]

int getUnpublishedNodesCount(Workspace $workspace)

Returns the number of unpublished nodes contained in the given workspace

Parameters

Workspace $workspace

Return Value

int

void publishNode(NodeInterface $node, Workspace $targetWorkspace = null)

Publishes the given node to the specified target workspace. If no workspace is specified, the base workspace is assumed.

If the given node is a Document or has ContentCollection child nodes, these nodes are published as well.

Parameters

NodeInterface $node
Workspace $targetWorkspace

If not set the "live" workspace is assumed to be the publishing target

Return Value

void

void publishNodes(array $nodes, Workspace $targetWorkspace = null)

Publishes the given nodes to the specified target workspace. If no workspace is specified, the source workspace's base workspace is assumed.

Parameters

array $nodes

The nodes to publish

Workspace $targetWorkspace

If not set the "live" workspace is assumed to be the publishing target

Return Value

void

void discardNode(NodeInterface $node)

Discards the given node from its workspace.

If the given node is a Document or has ContentCollection child nodes, these nodes are discarded as well.

Parameters

NodeInterface $node

Return Value

void

protected void doDiscardNode(NodeInterface $node, array $alreadyDiscardedNodeIdentifiers = [])

Method which does the actual work of discarding, includes a protection against endless recursions and multiple discarding of the same node.

Parameters

NodeInterface $node

The node to discard

array $alreadyDiscardedNodeIdentifiers

List of node identifiers which already have been discarded during one discardNode() run

Return Value

void

Exceptions

WorkspaceException

void discardNodes(array $nodes)

Discards the given nodes.

Parameters

array $nodes

The nodes to discard

Return Value

void

void discardAllNodes(Workspace $workspace)

Discards all unpublished nodes of the given workspace.

TODO: This method needs to be optimized / implemented in collaboration with a DQL-based method in NodeDataRepository

Parameters

Workspace $workspace

The workspace to flush, can't be the live workspace

Return Value

void

Exceptions

WorkspaceException

protected array sortNodesForPublishing(array $nodes)

Sort an unsorted list of nodes in a publishable order

Parameters

array $nodes

Unsorted list of nodes (unpublished nodes)

Return Value

array

Sorted list of nodes for publishing

Exceptions

WorkspaceException

void emitNodePublished(NodeInterface $node, Workspace $targetWorkspace = null)

Signals that a node has been published.

The signal emits the source node and target workspace, i.e. the node contains its source workspace.

Parameters

NodeInterface $node
Workspace $targetWorkspace

Return Value

void

void emitNodeDiscarded(NodeInterface $node)

Signals that a node has been discarded.

The signal emits the node that has been discarded.

Parameters

NodeInterface $node

Return Value

void

protected Context createContext(Workspace $workspace, array $dimensionValues, array $contextProperties = [])

Creates a new content context based on the given workspace and the NodeData object.

Parameters

Workspace $workspace

Workspace for the new context

array $dimensionValues

The dimension values for the new context

array $contextProperties

Additional pre-defined context properties

Return Value

Context

protected array collectAllContentChildNodes(NodeInterface $parentNode, array $collectedNodes = [])

No description

Parameters

NodeInterface $parentNode
array $collectedNodes

Return Value

array