ContextFactory
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 the context from the given properties. If a context with those properties was already created before then the existing one is returned.
Creates the actual Context instance.
Merges the given context properties with sane defaults for the context implementation.
Provides a way to identify a context to prevent duplicate context objects.
This creates the actual identifier and needs to be overridden by builders extending this.
No description
Removes context properties which have been previously allowed but are not supported anymore and should be silently ignored
No description
Reset instances (internal)
No description
No description
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.
protected Context
buildContextInstance(array $contextProperties)
Creates the actual Context instance.
This needs to be overridden if the Builder is extended.
protected array
mergeContextPropertiesWithDefaults(array $contextProperties)
Merges the given context properties with sane defaults for the context implementation.
protected string
getIdentifier(array $contextProperties)
Provides a way to identify a context to prevent duplicate context objects.
protected string
getIdentifierSource(array $contextProperties)
This creates the actual identifier and needs to be overridden by builders extending this.
protected void
validateContextProperties(array $contextProperties)
No description
protected array
removeDeprecatedProperties(array $contextProperties)
Removes context properties which have been previously allowed but are not supported anymore and should be silently ignored
protected ContentDimension[]
getAvailableDimensions()
No description
void
reset()
Reset instances (internal)
protected mixed
mergeTargetDimensionContextProperties(array $contextProperties, array $mergedProperties, array $defaultContextProperties)
No description
protected void
mergeDimensionValues(array $contextProperties, array $mergedProperties)
No description
Context[]
getInstances()
Returns all known instances of Context.