interface ContentTranslationHandlerInterface

Same name in other branches
  1. 8.9.x core/modules/content_translation/src/ContentTranslationHandlerInterface.php \Drupal\content_translation\ContentTranslationHandlerInterface
  2. 10 core/modules/content_translation/src/ContentTranslationHandlerInterface.php \Drupal\content_translation\ContentTranslationHandlerInterface
  3. 11.x core/modules/content_translation/src/ContentTranslationHandlerInterface.php \Drupal\content_translation\ContentTranslationHandlerInterface

Interface for providing content translation.

Defines a set of methods to allow any entity to be processed by the entity translation UI.

Hierarchy

Expanded class hierarchy of ContentTranslationHandlerInterface

All classes that implement ContentTranslationHandlerInterface

File

core/modules/content_translation/src/ContentTranslationHandlerInterface.php, line 14

Namespace

Drupal\content_translation
View source
interface ContentTranslationHandlerInterface {
    
    /**
     * Returns a set of field definitions to be used to store metadata items.
     *
     * @return \Drupal\Core\Field\FieldDefinitionInterface[]
     */
    public function getFieldDefinitions();
    
    /**
     * Checks that the user can perform the operation on the entity translation.
     *
     * @param \Drupal\Core\Entity\EntityInterface $entity
     *   The entity whose translation has to be accessed.
     * @param $op
     *   The operation to be performed on the translation. Possible values are:
     *   - "create"
     *   - "update"
     *   - "delete"
     *
     * @return \Drupal\Core\Access\AccessResultInterface
     *   The access result.
     */
    public function getTranslationAccess(EntityInterface $entity, $op);
    
    /**
     * Retrieves the source language for the translation being created.
     *
     * @param \Drupal\Core\Form\FormStateInterface $form_state
     *   The current state of the form.
     *
     * @return string
     *   The source language code.
     */
    public function getSourceLangcode(FormStateInterface $form_state);
    
    /**
     * Marks translations as outdated.
     *
     * @param \Drupal\Core\Entity\EntityInterface $entity
     *   The entity being translated.
     * @param string $langcode
     *   (optional) The language code of the updated language: all the other
     *   translations will be marked as outdated. Defaults to the entity language.
     */
    public function retranslate(EntityInterface $entity, $langcode = NULL);
    
    /**
     * Performs the needed alterations to the entity form.
     *
     * @param array $form
     *   The entity form to be altered to provide the translation workflow.
     * @param \Drupal\Core\Form\FormStateInterface $form_state
     *   The current state of the form.
     * @param \Drupal\Core\Entity\EntityInterface $entity
     *   The entity being created or edited.
     */
    public function entityFormAlter(array &$form, FormStateInterface $form_state, EntityInterface $entity);

}

Members

Title Sort descending Modifiers Object type Summary Overrides
ContentTranslationHandlerInterface::entityFormAlter public function Performs the needed alterations to the entity form. 1
ContentTranslationHandlerInterface::getFieldDefinitions public function Returns a set of field definitions to be used to store metadata items. 1
ContentTranslationHandlerInterface::getSourceLangcode public function Retrieves the source language for the translation being created. 1
ContentTranslationHandlerInterface::getTranslationAccess public function Checks that the user can perform the operation on the entity translation. 1
ContentTranslationHandlerInterface::retranslate public function Marks translations as outdated. 1

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.