PHP Class Neos\ContentRepository\Domain\Service\Context

Mostrar archivo Open project: neos/neos-development-collection Class Usage Examples

Protected Properties

Property Type Description
$contextFactory Neos\ContentRepository\Domain\Service\ContextFactoryInterface
$currentDateTime DateTime
$dimensions array
$firstLevelNodeCache Neos\ContentRepository\Domain\Service\Cache\FirstLevelNodeCache
$inaccessibleContentShown boolean If TRUE, even content elements will be shown which are not accessible by the currently logged in account.
$invisibleContentShown boolean If TRUE, invisible content elements will be shown.
$nodeDataRepository Neos\ContentRepository\Domain\Repository\NodeDataRepository
$nodeFactory Neos\ContentRepository\Domain\Factory\NodeFactory
$removedContentShown boolean If TRUE, removed content elements will be shown, even though they are removed.
$systemLogger Neos\Flow\Log\SystemLoggerInterface
$targetDimensions array
$workspace Neos\ContentRepository\Domain\Model\Workspace
$workspaceName string
$workspaceRepository Neos\ContentRepository\Domain\Repository\WorkspaceRepository

Public Methods

Method Description
__construct ( string $workspaceName, DateTimeInterface $currentDateTime, array $dimensions, array $targetDimensions, boolean $invisibleContentShown, boolean $removedContentShown, boolean $inaccessibleContentShown ) Creates a new Context object.
adoptNode ( Neos\ContentRepository\Domain\Model\NodeInterface $node, boolean $recursive = false ) : Neos\ContentRepository\Domain\Model\NodeInterface Adopts a node from a (possibly) different context to this context
getCurrentDateTime ( ) : DateTime Returns the current date and time in form of a \DateTime object.
getDimensions ( ) : array An indexed array of dimensions with ordered list of values for matching nodes by content dimensions
getFirstLevelNodeCache ( ) : FirstLevelNodeCache Not public API!
getNode ( string $path ) : Neos\ContentRepository\Domain\Model\NodeInterface Returns a node specified by the given absolute path.
getNodeByIdentifier ( string $identifier ) : Neos\ContentRepository\Domain\Model\NodeInterface Get a node by identifier and this context
getNodeVariantsByIdentifier ( string $identifier ) : array<\Neos\ContentRepository\Domain\Model\NodeInterface> Get all node variants for the given identifier
getNodesOnPath ( mixed $startingPoint, mixed $endPoint ) : array<\Neos\ContentRepository\Domain\Model\NodeInterface> Finds all nodes lying on the path specified by (and including) the given starting point and end point.
getProperties ( ) : array Returns the properties of this context.
getRootNode ( ) : Neos\ContentRepository\Domain\Model\NodeInterface Convenience method returns the root node for this context workspace.
getTargetDimensionValues ( ) : array An indexed array of dimensions with a set of values that should be applied when updating or creating
getTargetDimensions ( ) : array An indexed array of dimensions with a set of values that should be applied when updating or creating
getWorkspace ( boolean $createWorkspaceIfNecessary = true ) : Workspace Returns the current workspace.
getWorkspaceName ( ) : string Returns the name of the workspace.
isInaccessibleContentShown ( ) : boolean Tells if nodes which have access restrictions should be accessible through the Node API and queries even without the necessary roles / rights
isInvisibleContentShown ( ) : boolean Tells if nodes which are usually invisible should be accessible through the Node API and queries
isRemovedContentShown ( ) : boolean Tells if nodes which have their "removed" flag set should be accessible through the Node API and queries
validateWorkspace ( Workspace $workspace ) : void This method is called in order to check if a workspace is accessible.

Protected Methods

Method Description
emitAfterAdoptNode ( Neos\ContentRepository\Domain\Model\NodeInterface $node, Context $context, $recursive )
emitBeforeAdoptNode ( Neos\ContentRepository\Domain\Model\NodeInterface $node, Context $context, $recursive )

Method Details

__construct() public method

NOTE: This is for internal use only, you should use the ContextFactory for creating Context instances.
See also: ContextFactoryInterface
public __construct ( string $workspaceName, DateTimeInterface $currentDateTime, array $dimensions, array $targetDimensions, boolean $invisibleContentShown, boolean $removedContentShown, boolean $inaccessibleContentShown )
$workspaceName string Name of the current workspace
$currentDateTime DateTimeInterface The current date and time
$dimensions array Array of dimensions with array of ordered values
$targetDimensions array Array of dimensions used when creating / modifying content
$invisibleContentShown boolean If invisible content should be returned in query results
$removedContentShown boolean If removed content should be returned in query results
$inaccessibleContentShown boolean If inaccessible content should be returned in query results

adoptNode() public method

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.
public adoptNode ( Neos\ContentRepository\Domain\Model\NodeInterface $node, boolean $recursive = false ) : Neos\ContentRepository\Domain\Model\NodeInterface
$node Neos\ContentRepository\Domain\Model\NodeInterface 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.
$recursive boolean If TRUE also adopt all descendant nodes which are non-aggregate
return Neos\ContentRepository\Domain\Model\NodeInterface A new or existing node that matches this context

emitAfterAdoptNode() protected method

protected emitAfterAdoptNode ( Neos\ContentRepository\Domain\Model\NodeInterface $node, Context $context, $recursive )
$node Neos\ContentRepository\Domain\Model\NodeInterface
$context Context
$recursive

emitBeforeAdoptNode() protected method

protected emitBeforeAdoptNode ( Neos\ContentRepository\Domain\Model\NodeInterface $node, Context $context, $recursive )
$node Neos\ContentRepository\Domain\Model\NodeInterface
$context Context
$recursive

getCurrentDateTime() public method

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).
public getCurrentDateTime ( ) : DateTime
return DateTime The current date and time - or a simulated version of it

getDimensions() public method

An indexed array of dimensions with ordered list of values for matching nodes by content dimensions
public getDimensions ( ) : array
return array

getFirstLevelNodeCache() public method

Not public API!
public getFirstLevelNodeCache ( ) : FirstLevelNodeCache
return Neos\ContentRepository\Domain\Service\Cache\FirstLevelNodeCache

getNode() public method

Returns a node specified by the given absolute path.
public getNode ( string $path ) : Neos\ContentRepository\Domain\Model\NodeInterface
$path string Absolute path specifying the node
return Neos\ContentRepository\Domain\Model\NodeInterface The specified node or NULL if no such node exists

getNodeByIdentifier() public method

Get a node by identifier and this context
public getNodeByIdentifier ( string $identifier ) : Neos\ContentRepository\Domain\Model\NodeInterface
$identifier string The identifier of a node
return Neos\ContentRepository\Domain\Model\NodeInterface The node with the given identifier or NULL if no such node exists

getNodeVariantsByIdentifier() public method

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.
public getNodeVariantsByIdentifier ( string $identifier ) : array<\Neos\ContentRepository\Domain\Model\NodeInterface>
$identifier string The identifier of a node
return array<\Neos\ContentRepository\Domain\Model\NodeInterface>

getNodesOnPath() public method

Finds all nodes lying on the path specified by (and including) the given starting point and end point.
public getNodesOnPath ( mixed $startingPoint, mixed $endPoint ) : array<\Neos\ContentRepository\Domain\Model\NodeInterface>
$startingPoint mixed Either an absolute path or an actual node specifying the starting point, for example /sites/mysitecom
$endPoint mixed Either an absolute path or an actual node specifying the end point, for example /sites/mysitecom/homepage/subpage
return array<\Neos\ContentRepository\Domain\Model\NodeInterface>

getProperties() public method

Returns the properties of this context.
public getProperties ( ) : array
return array

getRootNode() public method

Convenience method returns the root node for this context workspace.
public getRootNode ( ) : Neos\ContentRepository\Domain\Model\NodeInterface
return Neos\ContentRepository\Domain\Model\NodeInterface

getTargetDimensionValues() public method

An indexed array of dimensions with a set of values that should be applied when updating or creating
public getTargetDimensionValues ( ) : array
return array

getTargetDimensions() public method

An indexed array of dimensions with a set of values that should be applied when updating or creating
public getTargetDimensions ( ) : array
return array

getWorkspace() public method

Returns the current workspace.
public getWorkspace ( boolean $createWorkspaceIfNecessary = true ) : Workspace
$createWorkspaceIfNecessary boolean 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 Neos\ContentRepository\Domain\Model\Workspace The workspace or NULL

getWorkspaceName() public method

Returns the name of the workspace.
public getWorkspaceName ( ) : string
return string

isInaccessibleContentShown() public method

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

isInvisibleContentShown() public method

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

isRemovedContentShown() public method

Tells if nodes which have their "removed" flag set should be accessible through the Node API and queries
public isRemovedContentShown ( ) : boolean
return boolean

validateWorkspace() public method

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.
public validateWorkspace ( Workspace $workspace ) : void
$workspace Neos\ContentRepository\Domain\Model\Workspace The workspace to check
return void

Property Details

$contextFactory protected_oe property

protected ContextFactoryInterface,Neos\ContentRepository\Domain\Service $contextFactory
return Neos\ContentRepository\Domain\Service\ContextFactoryInterface

$currentDateTime protected_oe property

protected DateTime $currentDateTime
return DateTime

$dimensions protected_oe property

protected array $dimensions
return array

$firstLevelNodeCache protected_oe property

protected FirstLevelNodeCache,Neos\ContentRepository\Domain\Service\Cache $firstLevelNodeCache
return Neos\ContentRepository\Domain\Service\Cache\FirstLevelNodeCache

$inaccessibleContentShown protected_oe property

If TRUE, even content elements will be shown which are not accessible by the currently logged in account.
protected bool $inaccessibleContentShown
return boolean

$invisibleContentShown protected_oe property

If TRUE, invisible content elements will be shown.
protected bool $invisibleContentShown
return boolean

$nodeDataRepository protected_oe property

protected NodeDataRepository,Neos\ContentRepository\Domain\Repository $nodeDataRepository
return Neos\ContentRepository\Domain\Repository\NodeDataRepository

$nodeFactory protected_oe property

protected NodeFactory,Neos\ContentRepository\Domain\Factory $nodeFactory
return Neos\ContentRepository\Domain\Factory\NodeFactory

$removedContentShown protected_oe property

If TRUE, removed content elements will be shown, even though they are removed.
protected bool $removedContentShown
return boolean

$systemLogger protected_oe property

protected SystemLoggerInterface,Neos\Flow\Log $systemLogger
return Neos\Flow\Log\SystemLoggerInterface

$targetDimensions protected_oe property

protected array $targetDimensions
return array

$workspace protected_oe property

protected Workspace,Neos\ContentRepository\Domain\Model $workspace
return Neos\ContentRepository\Domain\Model\Workspace

$workspaceName protected_oe property

protected string $workspaceName
return string

$workspaceRepository protected_oe property

protected WorkspaceRepository,Neos\ContentRepository\Domain\Repository $workspaceRepository
return Neos\ContentRepository\Domain\Repository\WorkspaceRepository