class ChildTranslationStrategy extends AttributeTranslationStrategy implements TranslationNodesWarmer (View source)

Translation strategy that stores the translations in a child nodes of the current node.

Constants

NAME

Identifier of this strategy.

NULLFIELDS

Properties

protected DocumentManagerInterface $dm from AbstractTranslationStrategy
protected string $prefix Prefix to namespace properties or child nodes. from AbstractTranslationStrategy

Methods

setPrefix(string $prefix)

Set the namespace alias for translation extra properties.

string
getTranslatedPropertyName(string $locale, $fieldName)

Determine the locale specific property name.

string
getTranslatedPropertyNameAssoc(string $locale, array $mapping)

Determine the locale specific property names for an assoc property.

saveTranslation(array $data, NodeInterface $node, ClassMetadata $metadata, string $locale)

Save the translatable fields of a node.

bool
loadTranslation(object $document, NodeInterface $node, ClassMetadata $metadata, string $locale)

Load the translatable fields of a node.

removeTranslation(object $document, NodeInterface $node, ClassMetadata $metadata, string $locale)

Remove the translated fields of a node in a given language.

removeAllTranslations(object $document, NodeInterface $node, ClassMetadata $metadata)

Removes all the translated fields for all translations of this node.

array
getLocalesFor(object $document, NodeInterface $node, ClassMetadata $metadata)

Get the list of locales persisted for this node.

array
getTranslatedPropertyPath(string $alias, string $propertyName, string $locale)

Get the location of the property for the base property name in a given language.

alterQueryForTranslation(QueryObjectModelFactoryInterface $qomf, SourceInterface $selector, ConstraintInterface $constraint = null, string $alias, string $locale)

This method allows a translation strategy to alter the query to integrate translations that are on other nodes.

bool|NodeInterface
getTranslationNode(NodeInterface $parentNode, string $locale, bool $create = true)

Get the child node with the translation. If create is true, the child node is created if not existing.

mixed
getTranslationsForNodes(NodeInterface[] $nodes, array $locales, SessionInterface $session)

This method will return all translations by the locale, but the main purpose of it is to warm up all translation nodes in one request to PHPCR.

Details

setPrefix(string $prefix)

Set the namespace alias for translation extra properties.

Parameters

string $prefix

string getTranslatedPropertyName(string $locale, $fieldName)

Determine the locale specific property name.

Parameters

string $locale
$fieldName

Return Value

string the property name with the translation namespace.

string getTranslatedPropertyNameAssoc(string $locale, array $mapping)

Determine the locale specific property names for an assoc property.

Parameters

string $locale
array $mapping the mapping for the property

Return Value

string the property name with the translation namespace.

saveTranslation(array $data, NodeInterface $node, ClassMetadata $metadata, string $locale)

Save the translatable fields of a node.

Parameters

array $data Data to save (field name => value to persist)
NodeInterface $node The physical node in the content repository
ClassMetadata $metadata The Doctrine metadata of the document
string $locale The language to persist the translations to

bool loadTranslation(object $document, NodeInterface $node, ClassMetadata $metadata, string $locale)

Load the translatable fields of a node.

Either loads all translatable fields into the document and returns true or returns false if this is not possible.

Parameters

object $document The document in which to load the data
NodeInterface $node The physical node in the content repository
ClassMetadata $metadata The Doctrine metadata of the document
string $locale The language to load the translations from

Return Value

bool true if the translation was completely loaded, false otherwise

removeTranslation(object $document, NodeInterface $node, ClassMetadata $metadata, string $locale)

Remove the translated fields of a node in a given language.

The document object is not altered by this operation.

Parameters

object $document The document from which the translations must be removed
NodeInterface $node The physical node in the content repository
ClassMetadata $metadata The Doctrine metadata of the document
string $locale The language to remove

removeAllTranslations(object $document, NodeInterface $node, ClassMetadata $metadata)

Removes all the translated fields for all translations of this node.

This will only be called just before the node itself is removed.

Parameters

object $document The document from which the translations must be removed
NodeInterface $node The physical node in the content repository
ClassMetadata $metadata The Doctrine metadata of the document

array getLocalesFor(object $document, NodeInterface $node, ClassMetadata $metadata)

Get the list of locales persisted for this node.

Parameters

object $document The document that must be checked
NodeInterface $node The Physical node in the content repository
ClassMetadata $metadata The Doctrine metadata of the document

Return Value

array with the locales strings

array getTranslatedPropertyPath(string $alias, string $propertyName, string $locale)

Get the location of the property for the base property name in a given language.

Parameters

string $alias The selector alias of the main node.
string $propertyName The base name of the translated property.
string $locale The requested locale.

Return Value

array with first alias, then the real property name.

alterQueryForTranslation(QueryObjectModelFactoryInterface $qomf, SourceInterface $selector, ConstraintInterface $constraint = null, string $alias, string $locale)

This method allows a translation strategy to alter the query to integrate translations that are on other nodes.

Only called once per alias value. The selector and constraint are passed by reference, the strategy can alter them to let the ConverterInterface instance generate a different query.

Parameters

QueryObjectModelFactoryInterface $qomf The PHPCR query factory.
SourceInterface $selector The current selector.
ConstraintInterface $constraint The current constraint, may be empty.
string $alias The selector alias of the main node.
string $locale The language to use.

protected bool|NodeInterface getTranslationNode(NodeInterface $parentNode, string $locale, bool $create = true)

Get the child node with the translation. If create is true, the child node is created if not existing.

Parameters

NodeInterface $parentNode
string $locale
bool $create whether to create the node if it is not yet existing

Return Value

bool|NodeInterface the node or false if $create is false and the node is not existing.

mixed getTranslationsForNodes(NodeInterface[] $nodes, array $locales, SessionInterface $session)

This method will return all translations by the locale, but the main purpose of it is to warm up all translation nodes in one request to PHPCR.

Parameters

NodeInterface[] $nodes
array $locales
SessionInterface $session

Return Value

mixed