interface TranslationStrategyInterface (View source)

Operations that a translation strategy must support.

A translation strategy is responsible for storing translations to PHPCR and retrieving them again.

Methods

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.

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

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

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

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

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.

Details

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

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

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

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.