Context
class Context (View source)
Context
Properties
protected WorkspaceRepository | $workspaceRepository | ||
protected NodeDataRepository | $nodeDataRepository | ||
protected NodeFactory | $nodeFactory | ||
protected ContextFactoryInterface | $contextFactory | ||
protected LoggerInterface | $systemLogger | ||
protected Workspace | $workspace | ||
protected string | $workspaceName | ||
protected DateTime | $currentDateTime | ||
protected bool | $invisibleContentShown | If true, invisible content elements will be shown. |
|
protected bool | $removedContentShown | If true, removed content elements will be shown, even though they are removed. |
|
protected bool | $inaccessibleContentShown | If true, even content elements will be shown which are not accessible by the currently logged in account. |
|
protected array | $dimensions | ||
protected array | $targetDimensions | ||
protected FirstLevelNodeCache | $firstLevelNodeCache |
Methods
Creates a new Context object.
Returns the current workspace.
This method is called in order to check if a workspace is accessible.
Returns the name of the workspace.
Returns the current date and time in form of a \DateTime object.
Convenience method returns the root node for this context workspace.
Returns a node specified by the given absolute path.
Get a node by identifier and this context
Get all node variants for the given identifier
Finds all nodes lying on the path specified by (and including) the given starting point and end point.
Adopts a node from a (possibly) different context to this context
Tells if nodes which are usually invisible should be accessible through the Node API and queries
Tells if nodes which have their "removed" flag set should be accessible through the Node API and queries
Tells if nodes which have access restrictions should be accessible through the Node API and queries even without the necessary roles / rights
An indexed array of dimensions with ordered list of values for matching nodes by content dimensions
An indexed array of dimensions with a set of values that should be applied when updating or creating
An indexed array of dimensions with a set of values that should be applied when updating or creating
Returns the properties of this context.
Not public API!
Details
__construct(string $workspaceName, DateTimeInterface $currentDateTime, array $dimensions, array $targetDimensions, bool $invisibleContentShown, bool $removedContentShown, bool $inaccessibleContentShown)
Creates a new Context object.
NOTE: This is for internal use only, you should use the ContextFactory for creating Context instances.
Workspace
getWorkspace(bool $createWorkspaceIfNecessary = true)
Returns the current workspace.
void
validateWorkspace(Workspace $workspace)
This method is called in order to check if a workspace is accessible.
At the time of this writing, it is not possible in Flow to restrict access to Workspace through Entity Privileges because Workspaces are used at a very early stage during routing where the security context is not yet initialized. As a workaround, we use a Method Privilege which protects this validateWorkspace() method and thus prevents unauthorized access to a workspace when calling this context's getWorkspace() method.
Since some privilege definitions check the "owner" property of a Workspace, we need a real Workspace object and not just the name - hence this method.
string
getWorkspaceName()
Returns the name of the workspace.
DateTime
getCurrentDateTime()
Returns the current date and time in form of a \DateTime object.
If you use this method for getting the current date and time everywhere in your code, it will be possible to simulate a certain time in unit tests or in the actual application (for realizing previews etc).
NodeInterface
getRootNode()
Convenience method returns the root node for this context workspace.
NodeInterface
getNode(string $path)
Returns a node specified by the given absolute path.
NodeInterface
getNodeByIdentifier(string $identifier)
Get a node by identifier and this context
NodeInterface[]
getNodeVariantsByIdentifier(string $identifier)
Get all node variants for the given identifier
A variant of a node can have different dimension values and path (for non-aggregate nodes). The resulting node instances might belong to a different context.
NodeInterface[]
getNodesOnPath(mixed $startingPoint, mixed $endPoint)
Finds all nodes lying on the path specified by (and including) the given starting point and end point.
NodeInterface
adoptNode(NodeInterface $node, bool $recursive = false)
Adopts a node from a (possibly) different context to this context
Checks if a node variant matching the exact dimensions already exists for this context and return it if found. Otherwise a new node variant for this context is created.
In case the node already exists in the context but does not match the target dimensions a new, more specific node is created and returned.
protected
emitBeforeAdoptNode(NodeInterface $node, Context $context, $recursive)
No description
protected
emitAfterAdoptNode(NodeInterface $node, Context $context, $recursive)
No description
bool
isInvisibleContentShown()
Tells if nodes which are usually invisible should be accessible through the Node API and queries
bool
isRemovedContentShown()
Tells if nodes which have their "removed" flag set should be accessible through the Node API and queries
bool
isInaccessibleContentShown()
Tells if nodes which have access restrictions should be accessible through the Node API and queries even without the necessary roles / rights
array
getDimensions()
An indexed array of dimensions with ordered list of values for matching nodes by content dimensions
array
getTargetDimensions()
An indexed array of dimensions with a set of values that should be applied when updating or creating
array
getTargetDimensionValues()
An indexed array of dimensions with a set of values that should be applied when updating or creating
array
getProperties()
Returns the properties of this context.
FirstLevelNodeCache
getFirstLevelNodeCache()
Not public API!