You are here

protected function InlineEntityFormBase::isTranslating in Inline Entity Form 8

Determines whether there's a translation in progress.

Ensures that at least one target bundle has translations enabled. Otherwise the widget will skip translation even if it's happening on the parent form itself.

Parameters

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

Return value

bool TRUE if translating is in progress, FALSE otherwise.

See also

\Drupal\inline_entity_form\TranslationHelper::initFormLangcodes()

1 call to InlineEntityFormBase::isTranslating()
InlineEntityFormComplex::formElement in src/Plugin/Field/FieldWidget/InlineEntityFormComplex.php
Returns the form for a single field widget.

File

src/Plugin/Field/FieldWidget/InlineEntityFormBase.php, line 461

Class

InlineEntityFormBase
Inline entity form widget base class.

Namespace

Drupal\inline_entity_form\Plugin\Field\FieldWidget

Code

protected function isTranslating(FormStateInterface $form_state) {
  if (TranslationHelper::isTranslating($form_state)) {
    $translation_manager = \Drupal::service('content_translation.manager');
    $target_type = $this
      ->getFieldSetting('target_type');
    foreach ($this
      ->getTargetBundles() as $bundle) {
      if ($translation_manager
        ->isEnabled($target_type, $bundle)) {
        return TRUE;
      }
    }
  }
  return FALSE;
}