You are here

public static function TranslationHelper::isTranslating in Inline Entity Form 8

Determines whether there's a translation in progress.

If the root entity is being translated, then all of the inline entities are candidates for translating as well.

Parameters

\Drupal\Core\Form\FormStateInterface $form_state: The form state.

Return value

bool TRUE if translating is in progress, FALSE otherwise.

See also

\Drupal\Core\Entity\ContentEntityForm::initFormLangcodes()

3 calls to TranslationHelper::isTranslating()
InlineEntityForm::processEntityForm in src/Element/InlineEntityForm.php
Builds the entity form using the inline form handler.
InlineEntityFormBase::isTranslating in src/Plugin/Field/FieldWidget/InlineEntityFormBase.php
Determines whether there's a translation in progress.
TranslationHelper::prepareEntity in src/TranslationHelper.php
Prepares the inline entity for translation.

File

src/TranslationHelper.php, line 105

Class

TranslationHelper
Provides content translation helpers.

Namespace

Drupal\inline_entity_form

Code

public static function isTranslating(FormStateInterface $form_state) {
  $form_langcode = $form_state
    ->get('langcode');
  $default_langcode = $form_state
    ->get('entity_default_langcode');
  if (empty($form_langcode) && empty($default_langcode)) {

    // The top-level form is not a content entity form.
    return FALSE;
  }
  else {
    return $form_langcode != $default_langcode;
  }
}