You are here

private static function LayoutBuilder::hasTranslatableConfiguration in Layout Builder Symmetric Translations 8

Determines whether the component has translatable configuration.

This function is replacement for \Drupal\layout_builder\SectionComponent::hasTranslatableConfiguration() in https://www.drupal.org/project/drupal/issues/2946333#comment-13129737 This avoids having to alter the class in the module.

Parameters

\Drupal\layout_builder\SectionComponent $component:

Return value

bool TRUE if the plugin has translatable configuration.

File

src/Element/LayoutBuilder.php, line 191

Class

LayoutBuilder
Extended LayoutBuilder element to remove actions for translations.

Namespace

Drupal\layout_builder_st\Element

Code

private static function hasTranslatableConfiguration(SectionComponent $component) {
  $plugin = $component
    ->getPlugin();
  if ($plugin instanceof LayoutBuilderTranslatablePluginInterface) {
    return $plugin
      ->hasTranslatableConfiguration();
  }
  elseif ($plugin instanceof ConfigurableInterface) {

    // For all plugins that do not implement
    // LayoutBuilderTranslatablePluginInterface only allow label translation.
    $configuration = $plugin
      ->getConfiguration();
    return !empty($configuration['label_display']) && !empty($configuration['label']);
  }
  return FALSE;
}