You are here

protected function LayoutParagraphsBuilder::isTranslating in Layout Paragraphs 2.0.x

Returns TRUE if in translation context.

Return value

bool TRUE if translating.

5 calls to LayoutParagraphsBuilder::isTranslating()
LayoutParagraphsBuilder::createAccess in src/Element/LayoutParagraphsBuilder.php
Returns an AccessResult object.
LayoutParagraphsBuilder::deleteAccess in src/Element/LayoutParagraphsBuilder.php
Returns an AccessResult object.
LayoutParagraphsBuilder::initTranslations in src/Element/LayoutParagraphsBuilder.php
Initialize translations for item list.
LayoutParagraphsBuilder::preRender in src/Element/LayoutParagraphsBuilder.php
Pre-render callback: Renders the UI.
LayoutParagraphsBuilder::translationWarning in src/Element/LayoutParagraphsBuilder.php
Builds a translation warning message.

File

src/Element/LayoutParagraphsBuilder.php, line 576

Class

LayoutParagraphsBuilder
Defines a render element for building the Layout Builder UI.

Namespace

Drupal\layout_paragraphs\Element

Code

protected function isTranslating() {
  if (is_null($this->isTranslating)) {
    $this->isTranslating = FALSE;

    /** @var \Drupal\Core\Entity\ContentEntityInterface $host */
    $host = $this->layoutParagraphsLayout
      ->getEntity();
    $default_langcode_key = $host
      ->getEntityType()
      ->getKey('default_langcode');
    if ($host
      ->hasTranslation($this->langcode) && $host
      ->getTranslation($this->langcode)
      ->get($default_langcode_key)->value == 0) {
      $this->isTranslating = TRUE;
    }
  }
  return $this->isTranslating;
}