You are here

protected function InlineParagraphsWidget::getCurrentLangcode in Paragraphs 8

Gets current language code from the form state or item.

Since the paragraph field is not set as translatable, the item language code is set to the source language. The intended translation language is only accessibly through the form state.

Parameters

\Drupal\Core\Form\FormStateInterface $form_state:

\Drupal\Core\Field\FieldItemListInterface $items:

Return value

string

File

src/Plugin/Field/FieldWidget/InlineParagraphsWidget.php, line 1133

Class

InlineParagraphsWidget
Plugin implementation of the 'entity_reference paragraphs' widget.

Namespace

Drupal\paragraphs\Plugin\Field\FieldWidget

Code

protected function getCurrentLangcode(FormStateInterface $form_state, FieldItemListInterface $items) {
  return $form_state
    ->get('langcode') ?: $items
    ->getEntity()
    ->language()
    ->getId();
}