class PublishingService implements PublishingServiceInterface (View source)

A generic ContentRepository Publishing Service

Properties

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

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 source workspace's 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.

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.

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 source workspace's base workspace is assumed.

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.

If the node has been moved, this method will also discard all changes of child nodes of the given node.

Parameters

NodeInterface $node

Return Value

void

Exceptions

WorkspaceException

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