Drupal 8  8.0.2
ContentTranslationHandler Class Reference
Inheritance diagram for ContentTranslationHandler:

Public Member Functions

 __construct (EntityTypeInterface $entity_type, LanguageManagerInterface $language_manager, ContentTranslationManagerInterface $manager, EntityManagerInterface $entity_manager, AccountInterface $current_user)
 
 getFieldDefinitions ()
 
 retranslate (EntityInterface $entity, $langcode=NULL)
 
 getTranslationAccess (EntityInterface $entity, $op)
 
 getSourceLangcode (FormStateInterface $form_state)
 
 entityFormAlter (array &$form, FormStateInterface $form_state, EntityInterface $entity)
 
 entityFormSharedElements ($element, FormStateInterface $form_state, $form)
 
 entityFormEntityBuild ($entity_type, EntityInterface $entity, array $form, FormStateInterface $form_state)
 
 entityFormValidate ($form, FormStateInterface $form_state)
 
 entityFormSourceChange ($form, FormStateInterface $form_state)
 
 entityFormDelete ($form, FormStateInterface $form_state)
 

Static Public Member Functions

static createInstance (ContainerInterface $container, EntityTypeInterface $entity_type)
 
static getDefaultOwnerId ()
 

Protected Member Functions

 hasAuthor ()
 
 hasPublishedStatus ()
 
 hasChangedTime ()
 
 hasCreatedTime ()
 
 checkFieldStorageDefinitionTranslatability ($field_name)
 
 addTranslatabilityClue (&$element)
 
 entityFormTitle (EntityInterface $entity)
 

Protected Attributes

 $entityTypeId
 
 $entityType
 
 $languageManager
 
 $manager
 
 $currentUser
 
 $fieldStorageDefinitions
 

Detailed Description

Base class for content translation handlers.

Constructor & Destructor Documentation

__construct ( EntityTypeInterface  $entity_type,
LanguageManagerInterface  $language_manager,
ContentTranslationManagerInterface  $manager,
EntityManagerInterface  $entity_manager,
AccountInterface  $current_user 
)

Initializes an instance of the content translation controller.

Parameters
\Drupal\Core\Entity\EntityTypeInterface$entity_typeThe info array of the given entity type.
\Drupal\Core\Language\LanguageManagerInterface$language_managerThe language manager.
\Drupal\content_translation\ContentTranslationManagerInterface$managerThe content translation manager service.
\Drupal\Core\Entity\EntityManagerInterface$entity_managerThe entity manager.
\Drupal\Core\Session\AccountInterface$current_userThe current user.

References Drupal\currentUser(), EntityManagerInterface\getLastInstalledFieldStorageDefinitions(), EntityTypeInterface\id(), and Drupal\languageManager().

Here is the call graph for this function:

Member Function Documentation

addTranslatabilityClue ( $element)
protected

Adds a clue about the form element translatability.

If the given element does not have a #title attribute, the function is recursively applied to child elements.

Parameters
array$elementA form element array.

References Element\children(), and t().

Referenced by ContentTranslationHandler\entityFormSharedElements().

Here is the call graph for this function:

Here is the caller graph for this function:

checkFieldStorageDefinitionTranslatability (   $field_name)
protected

Checks the field storage definition for translatability support.

Checks whether the given field is defined in the field storage definitions and if its definition specifies it as translatable.

Parameters
string$field_nameThe name of the field.
Returns
bool TRUE if translatable field storage definition exists, FALSE otherwise.

Referenced by ContentTranslationHandler\hasAuthor(), ContentTranslationHandler\hasChangedTime(), ContentTranslationHandler\hasCreatedTime(), and ContentTranslationHandler\hasPublishedStatus().

Here is the caller graph for this function:

static createInstance ( ContainerInterface  $container,
EntityTypeInterface  $entity_type 
)
static

{Instantiates a new instance of this entity handler.This is a factory method that returns a new instance of this object. The factory should pass any needed dependencies into the constructor of this object, but not the container itself. Every call to this method must return a new instance of this object; that is, it may not implement a singleton.

Parameters
\Symfony\Component\DependencyInjection\ContainerInterface$containerThe service container this object should use.
\Drupal\Core\Entity\EntityTypeInterface$entity_typeThe entity type definition.
Returns
static A new instance of the entity handler.
}

Implements EntityHandlerInterface.

References EntityTypeInterface\get().

Here is the call graph for this function:

entityFormAlter ( array &  $form,
FormStateInterface  $form_state,
EntityInterface  $entity 
)

{Performs the needed alterations to the entity form.

Parameters
array$formThe entity form to be altered to provide the translation workflow.
\Drupal\Core\Form\FormStateInterface$form_stateThe current state of the form.
\Drupal\Core\Entity\EntityInterface$entityThe entity being created or edited.
}

Implements ContentTranslationHandlerInterface.

References AccessibleInterface\access(), Element\children(), Drupal\config(), Drupal\currentUser(), ContentTranslationHandler\entityFormTitle(), format_date(), FormStateInterface\getFormObject(), ContentTranslationHandler\getSourceLangcode(), ContentTranslationHandler\getTranslationAccess(), EntityInterface\label(), EntityInterface\language(), Drupal\languageManager(), Entity\load(), and t().

Here is the call graph for this function:

entityFormDelete (   $form,
FormStateInterface  $form_state 
)

Form submission handler for ContentTranslationHandler::entityFormAlter().

Takes care of entity deletion.

References FormStateInterface\getFormObject(), and t().

Here is the call graph for this function:

entityFormEntityBuild (   $entity_type,
EntityInterface  $entity,
array  $form,
FormStateInterface  $form_state 
)

Entity builder method.

Parameters
string$entity_typeThe type of the entity.
\Drupal\Core\Entity\EntityInterface$entityThe entity whose form is being built.
See Also
::entityFormAlter()

References FormStateInterface\getFormObject(), ContentTranslationHandler\getSourceLangcode(), FormStateInterface\getValue(), Entity\load(), and ContentTranslationHandler\retranslate().

Here is the call graph for this function:

entityFormSharedElements (   $element,
FormStateInterface  $form_state,
  $form 
)

Process callback: determines which elements get clue in the form.

See Also
::entityFormAlter()

References ContentTranslationHandler\addTranslatabilityClue(), Element\children(), and FormStateInterface\get().

Here is the call graph for this function:

entityFormSourceChange (   $form,
FormStateInterface  $form_state 
)

Form submission handler for ContentTranslationHandler::entityFormAlter().

Takes care of the source language change.

References FormStateInterface\getFormObject(), FormStateInterface\getValue(), Drupal\languageManager(), FormStateInterface\setRedirect(), and t().

Here is the call graph for this function:

entityFormTitle ( EntityInterface  $entity)
protected

Returns the title to be used for the entity form page.

Parameters
\Drupal\Core\Entity\EntityInterface$entityThe entity whose form is being altered.

References EntityInterface\label().

Referenced by ContentTranslationHandler\entityFormAlter().

Here is the call graph for this function:

Here is the caller graph for this function:

entityFormValidate (   $form,
FormStateInterface  $form_state 
)

Form validation handler for ContentTranslationHandler::entityFormAlter().

Validates the submitted content translation metadata.

References FormStateInterface\getValue(), FormStateInterface\isValueEmpty(), Entity\load(), FormStateInterface\setErrorByName(), and t().

Here is the call graph for this function:

static getDefaultOwnerId ( )
static

Default value callback for the owner base field definition.

Returns
int The user ID.
getFieldDefinitions ( )

{Returns a set of field definitions to be used to store metadata items.

Returns
[]
}

Implements ContentTranslationHandlerInterface.

References BaseFieldDefinition\create(), ContentTranslationHandler\hasAuthor(), ContentTranslationHandler\hasChangedTime(), ContentTranslationHandler\hasCreatedTime(), ContentTranslationHandler\hasPublishedStatus(), LanguageInterface\LANGCODE_NOT_SPECIFIED, and t().

Here is the call graph for this function:

getSourceLangcode ( FormStateInterface  $form_state)

{Retrieves the source language for the translation being created.

Parameters
\Drupal\Core\Form\FormStateInterface$form_stateThe current state of the form.
Returns
string The source language code.
}

Implements ContentTranslationHandlerInterface.

References FormStateInterface\get().

Referenced by ContentTranslationHandler\entityFormAlter(), ContentTranslationHandler\entityFormEntityBuild(), TermTranslationHandler\entityFormSave(), and ProfileTranslationHandler\entityFormSave().

Here is the call graph for this function:

Here is the caller graph for this function:

getTranslationAccess ( EntityInterface  $entity,
  $op 
)

{Checks if the user can perform the given operation on translations of the wrapped entity.

Parameters
\Drupal\Core\Entity\EntityInterface$entityThe entity whose translation has to be accessed.
$opThe operation to be performed on the translation. Possible values are:
  • "create"
  • "update"
  • "delete"
Returns
The access result.
}

Implements ContentTranslationHandlerInterface.

References AccessResult\allowedIf(), Drupal\currentUser(), and EntityInterface\getEntityType().

Referenced by ContentTranslationHandler\entityFormAlter().

Here is the call graph for this function:

Here is the caller graph for this function:

hasAuthor ( )
protected

Checks whether the entity type supports author natively.

Returns
bool TRUE if metadata is natively supported, FALSE otherwise.

References ContentTranslationHandler\checkFieldStorageDefinitionTranslatability().

Referenced by ContentTranslationHandler\getFieldDefinitions().

Here is the call graph for this function:

Here is the caller graph for this function:

hasChangedTime ( )
protected

Checks whether the entity type supports modification time natively.

Returns
bool TRUE if metadata is natively supported, FALSE otherwise.

References ContentTranslationHandler\checkFieldStorageDefinitionTranslatability().

Referenced by ContentTranslationHandler\getFieldDefinitions().

Here is the call graph for this function:

Here is the caller graph for this function:

hasCreatedTime ( )
protected

Checks whether the entity type supports creation time natively.

Returns
bool TRUE if metadata is natively supported, FALSE otherwise.

References ContentTranslationHandler\checkFieldStorageDefinitionTranslatability().

Referenced by ContentTranslationHandler\getFieldDefinitions().

Here is the call graph for this function:

Here is the caller graph for this function:

hasPublishedStatus ( )
protected

Checks whether the entity type supports published status natively.

Returns
bool TRUE if metadata is natively supported, FALSE otherwise.

References ContentTranslationHandler\checkFieldStorageDefinitionTranslatability().

Referenced by ContentTranslationHandler\getFieldDefinitions().

Here is the call graph for this function:

Here is the caller graph for this function:

retranslate ( EntityInterface  $entity,
  $langcode = NULL 
)

{Marks translations as outdated.

Parameters
\Drupal\Core\Entity\EntityInterface$entityThe entity being translated.
string$langcode(optional) The language code of the updated language: all the other translations will be marked as outdated. Defaults to the entity language.
}

Implements ContentTranslationHandlerInterface.

References EntityInterface\language().

Referenced by ContentTranslationHandler\entityFormEntityBuild().

Here is the call graph for this function:

Here is the caller graph for this function:


The documentation for this class was generated from the following file: