class ContentContext extends Context (View source)

The Content Context

Properties

protected WorkspaceRepository $workspaceRepository from  Context
protected NodeDataRepository $nodeDataRepository from  Context
protected NodeFactory $nodeFactory from  Context
protected ContextFactoryInterface $contextFactory from  Context
protected LoggerInterface $systemLogger from  Context
protected Workspace $workspace from  Context
protected string $workspaceName from  Context
protected DateTime $currentDateTime from  Context
protected bool $invisibleContentShown

If true, invisible content elements will be shown.

from  Context
protected bool $removedContentShown

If true, removed content elements will be shown, even though they are removed.

from  Context
protected bool $inaccessibleContentShown

If true, even content elements will be shown which are not accessible by the currently logged in account.

from  Context
protected array $dimensions from  Context
protected array $targetDimensions from  Context
protected FirstLevelNodeCache $firstLevelNodeCache from  Context
protected Site $currentSite
protected Domain $currentDomain
protected NodeInterface $currentSiteNode
protected PrivilegeManagerInterface $privilegeManager
protected UserInterfaceModeService $interfaceRenderModeService

Methods

__construct(string $workspaceName, DateTimeInterface $currentDateTime, array $dimensions, array $targetDimensions, bool $invisibleContentShown, bool $removedContentShown, bool $inaccessibleContentShown, Site $currentSite = null, Domain $currentDomain = null)

Creates a new Content Context object.

getWorkspace(bool $createWorkspaceIfNecessary = true)

Returns the current workspace.

from  Context
void
validateWorkspace(Workspace $workspace)

This method is called in order to check if a workspace is accessible.

from  Context
string
getWorkspaceName()

Returns the name of the workspace.

from  Context
getCurrentDateTime()

Returns the current date and time in form of a \DateTime object.

from  Context
getRootNode()

Convenience method returns the root node for this context workspace.

from  Context
getNode(string $path)

Returns a node specified by the given absolute path.

from  Context
getNodeByIdentifier(string $identifier)

Get a node by identifier and this context

from  Context
getNodeVariantsByIdentifier(string $identifier)

Get all node variants for the given identifier

from  Context
getNodesOnPath(mixed $startingPoint, mixed $endPoint)

Finds all nodes lying on the path specified by (and including) the given starting point and end point.

from  Context
adoptNode(NodeInterface $node, bool $recursive = false)

Adopts a node from a (possibly) different context to this context

from  Context
emitBeforeAdoptNode(NodeInterface $node, Context $context, $recursive)

No description

from  Context
emitAfterAdoptNode(NodeInterface $node, Context $context, $recursive)

No description

from  Context
bool
isInvisibleContentShown()

Tells if nodes which are usually invisible should be accessible through the Node API and queries

from  Context
bool
isRemovedContentShown()

Tells if nodes which have their "removed" flag set should be accessible through the Node API and queries

from  Context
bool
isInaccessibleContentShown()

Tells if nodes which have access restrictions should be accessible through the Node API and queries even without the necessary roles / rights

from  Context
array
getDimensions()

An indexed array of dimensions with ordered list of values for matching nodes by content dimensions

from  Context
array
getTargetDimensions()

An indexed array of dimensions with a set of values that should be applied when updating or creating

from  Context
array
getTargetDimensionValues()

An indexed array of dimensions with a set of values that should be applied when updating or creating

from  Context
array
getProperties()

Returns the properties of this context.

getCurrentSite()

Returns the current site from this frontend context

getCurrentDomain()

Returns the current domain from this frontend context

getCurrentSiteNode()

Returns the node of the current site.

bool
isLive()

Returns true if current context is live workspace, false otherwise

bool
isInBackend()

Returns true while rendering backend (not live workspace and access to backend granted), false otherwise

bool
hasAccessToBackend()

Is access to the neos backend granted by current authentications.

Details

__construct(string $workspaceName, DateTimeInterface $currentDateTime, array $dimensions, array $targetDimensions, bool $invisibleContentShown, bool $removedContentShown, bool $inaccessibleContentShown, Site $currentSite = null, Domain $currentDomain = null)

Creates a new Content Context object.

NOTE: This is for internal use only, you should use the ContextFactory for creating Context instances.

Parameters

string $workspaceName

Name of the current workspace

DateTimeInterface $currentDateTime

The current date and time

array $dimensions

Array of dimensions with array of ordered values

array $targetDimensions

Array of dimensions used when creating / modifying content

bool $invisibleContentShown

If invisible content should be returned in query results

bool $removedContentShown

If removed content should be returned in query results

bool $inaccessibleContentShown

If inaccessible content should be returned in query results

Site $currentSite

The current Site object

Domain $currentDomain

The current Domain object

See also

ContextFactoryInterface

Workspace getWorkspace(bool $createWorkspaceIfNecessary = true)

Returns the current workspace.

Parameters

bool $createWorkspaceIfNecessary

DEPRECATED: If enabled, creates a workspace with the configured name if it doesn't exist already. This option is DEPRECATED, create workspace explicitly instead.

Return Value

Workspace

The workspace or NULL

Exceptions

IllegalObjectTypeException

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.

Parameters

Workspace $workspace

The workspace to check

Return Value

void

string getWorkspaceName()

Returns the name of the workspace.

Return Value

string

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

Return Value

DateTime

The current date and time - or a simulated version of it

NodeInterface getRootNode()

Convenience method returns the root node for this context workspace.

Return Value

NodeInterface

NodeInterface getNode(string $path)

Returns a node specified by the given absolute path.

Parameters

string $path

Absolute path specifying the node

Return Value

NodeInterface

The specified node or NULL if no such node exists

Exceptions

InvalidArgumentException

NodeInterface getNodeByIdentifier(string $identifier)

Get a node by identifier and this context

Parameters

string $identifier

The identifier of a node

Return Value

NodeInterface

The node with the given identifier or NULL if no such node exists

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.

Parameters

string $identifier

The identifier of a node

Return Value

NodeInterface[]

NodeInterface[] getNodesOnPath(mixed $startingPoint, mixed $endPoint)

Finds all nodes lying on the path specified by (and including) the given starting point and end point.

Parameters

mixed $startingPoint

Either an absolute path or an actual node specifying the starting point, for example /sites/mysitecom

mixed $endPoint

Either an absolute path or an actual node specifying the end point, for example /sites/mysitecom/homepage/subpage

Return Value

NodeInterface[]

The nodes found between and including the given paths or an empty array of none were found

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.

Parameters

NodeInterface $node

The node with a different context. If the context of the given node is the same as this context the operation will have no effect.

bool $recursive

If true also adopt all descendant nodes which are non-aggregate

Return Value

NodeInterface

A new or existing node that matches this context

protected emitBeforeAdoptNode(NodeInterface $node, Context $context, $recursive)

No description

Parameters

NodeInterface $node
Context $context
$recursive

protected emitAfterAdoptNode(NodeInterface $node, Context $context, $recursive)

No description

Parameters

NodeInterface $node
Context $context
$recursive

bool isInvisibleContentShown()

Tells if nodes which are usually invisible should be accessible through the Node API and queries

Return Value

bool

See also

NodeFactory->filterNodeByContext()

bool isRemovedContentShown()

Tells if nodes which have their "removed" flag set should be accessible through the Node API and queries

Return Value

bool

See also

Node->filterNodeByContext()

bool isInaccessibleContentShown()

Tells if nodes which have access restrictions should be accessible through the Node API and queries even without the necessary roles / rights

Return Value

bool

array getDimensions()

An indexed array of dimensions with ordered list of values for matching nodes by content dimensions

Return Value

array

array getTargetDimensions()

An indexed array of dimensions with a set of values that should be applied when updating or creating

Return Value

array

array getTargetDimensionValues()

An indexed array of dimensions with a set of values that should be applied when updating or creating

Return Value

array

array getProperties()

Returns the properties of this context.

Return Value

array

FirstLevelNodeCache getFirstLevelNodeCache()

Not public API!

Return Value

FirstLevelNodeCache

Site getCurrentSite()

Returns the current site from this frontend context

Return Value

Site

The current site

Domain getCurrentDomain()

Returns the current domain from this frontend context

Return Value

Domain

The current domain

NodeInterface getCurrentSiteNode()

Returns the node of the current site.

Return Value

NodeInterface

bool isLive()

Returns true if current context is live workspace, false otherwise

Return Value

bool

Exceptions

IllegalObjectTypeException

bool isInBackend()

Returns true while rendering backend (not live workspace and access to backend granted), false otherwise

Return Value

bool

Exceptions

IllegalObjectTypeException

UserInterfaceMode getCurrentRenderingMode()

No description

Return Value

UserInterfaceMode

protected bool hasAccessToBackend()

Is access to the neos backend granted by current authentications.

Return Value

bool