class ContextFactory implements ContextFactoryInterface (View source)

The ContextFactory makes sure you don't create context instances with the same properties twice. Calling create() with the same parameters a second time will return the same Context instance again.

Refer to 'ContextFactoryInterface' instead of 'ContextFactory' when injecting this factory into your own class.

Properties

protected Context[] $contextInstances
protected string $contextImplementation

The context implementation this factory will create

protected ContentDimensionRepository $contentDimensionRepository
protected Now $now
protected Context $securityContext

Methods

create(array $contextProperties = [])

Create the context from the given properties. If a context with those properties was already created before then the existing one is returned.

buildContextInstance(array $contextProperties)

Creates the actual Context instance.

array
mergeContextPropertiesWithDefaults(array $contextProperties)

Merges the given context properties with sane defaults for the context implementation.

string
getIdentifier(array $contextProperties)

Provides a way to identify a context to prevent duplicate context objects.

string
getIdentifierSource(array $contextProperties)

This creates the actual identifier and needs to be overridden by builders extending this.

void
validateContextProperties(array $contextProperties)

No description

array
removeDeprecatedProperties(array $contextProperties)

Removes context properties which have been previously allowed but are not supported anymore and should be silently ignored

void
reset()

Reset instances (internal)

mixed
mergeTargetDimensionContextProperties(array $contextProperties, array $mergedProperties, array $defaultContextProperties)

No description

void
mergeDimensionValues(array $contextProperties, array $mergedProperties)

No description

getInstances()

Returns all known instances of Context.

Details

Context create(array $contextProperties = [])

Create the context from the given properties. If a context with those properties was already created before then the existing one is returned.

The context properties to give depend on the implementation of the context object, for the Neos\ContentRepository\Domain\Service\Context it should look like this:

array( 'workspaceName' => 'live', 'currentDateTime' => new \Neos\Flow\Utility\Now(), 'dimensions' => array(...), 'targetDimensions' => array('language' => 'de', 'persona' => 'Lisa'), 'invisibleContentShown' => false, 'removedContentShown' => false, 'inaccessibleContentShown' => false )

This array also shows the defaults that get used if you don't provide a certain property.

Parameters

array $contextProperties

Return Value

Context

protected Context buildContextInstance(array $contextProperties)

Creates the actual Context instance.

This needs to be overridden if the Builder is extended.

Parameters

array $contextProperties

Return Value

Context

protected array mergeContextPropertiesWithDefaults(array $contextProperties)

Merges the given context properties with sane defaults for the context implementation.

Parameters

array $contextProperties

Return Value

array

protected string getIdentifier(array $contextProperties)

Provides a way to identify a context to prevent duplicate context objects.

Parameters

array $contextProperties

Return Value

string

protected string getIdentifierSource(array $contextProperties)

This creates the actual identifier and needs to be overridden by builders extending this.

Parameters

array $contextProperties

Return Value

string

protected void validateContextProperties(array $contextProperties)

No description

Parameters

array $contextProperties

Return Value

void

Exceptions

InvalidNodeContextException

protected array removeDeprecatedProperties(array $contextProperties)

Removes context properties which have been previously allowed but are not supported anymore and should be silently ignored

Parameters

array $contextProperties

Return Value

array

protected ContentDimension[] getAvailableDimensions()

No description

Return Value

ContentDimension[]

void reset()

Reset instances (internal)

Return Value

void

protected mixed mergeTargetDimensionContextProperties(array $contextProperties, array $mergedProperties, array $defaultContextProperties)

No description

Parameters

array $contextProperties
array $mergedProperties
array $defaultContextProperties

Return Value

mixed

protected void mergeDimensionValues(array $contextProperties, array $mergedProperties)

No description

Parameters

array $contextProperties
array $mergedProperties

Return Value

void

Exceptions

InvalidNodeContextException

Context[] getInstances()

Returns all known instances of Context.

Return Value

Context[]