class NodePublishingDependencySolver (View source)

Solve / sort nodes by dependencies for publishing

Properties

protected array $nodesByPath
protected array $nodesByNodeData
protected array $dependenciesOutgoing
protected array $dependenciesIncoming
protected array $nodesWithoutIncoming

Methods

array
sort(array $nodes)

Sort nodes by an order suitable for publishing

buildNodeDependencies(array $nodes)

Prepare dependencies for the given list of nodes

array
resolveDependencies()

Resolve node dependencies

Details

array sort(array $nodes)

Sort nodes by an order suitable for publishing

This makes sure all parent and moved-to relations are resolved and changes that need to be published before other changes will be published first.

Uses topological sorting of node dependencies (http://en.wikipedia.org/wiki/Topological_sorting) to build a publishable order of nodes.

Parameters

array $nodes

Array of nodes to sort, if dependencies are missing in this list an exception will be thrown

Return Value

array

Array of nodes sorted by dependencies for publishing

Exceptions

WorkspaceException

protected buildNodeDependencies(array $nodes)

Prepare dependencies for the given list of nodes

Parameters

array $nodes

Unsorted list of nodes

Exceptions

WorkspaceException

protected array resolveDependencies()

Resolve node dependencies

  1. Pick a node from the set of nodes without incoming dependencies
  2. For all dependencies of that node: 2a. Remove the dependency 2b. If the dependency has no other incoming dependencies itself, add it to the set of nodes without incoming dependencies

Return Value

array

Sorted list of nodes (not all dependencies might be solved)