You are here

public function ContentLanguageSettings::onImportUpdate in Acquia Content Hub 8.2

Handles the importing of existing ContentLanguageSettings entities.

Parameters

\Drupal\acquia_contenthub\Event\EntityImportEvent $event: The entity import event.

File

src/EventSubscriber/EntityImport/ContentLanguageSettings.php, line 54

Class

ContentLanguageSettings
Handles ContentLanguageSetting entity saves to apply related schema.

Namespace

Drupal\acquia_contenthub\EventSubscriber\EntityImport

Code

public function onImportUpdate(EntityImportEvent $event) {
  $settings = $event
    ->getEntity();

  // Early return if this isn't the class of entity we care about.
  if (!$settings instanceof ContentLanguageSettingsInterface) {
    return;
  }

  /** @var \Drupal\language\ContentLanguageSettingsInterface $original_settings */
  $original_settings = $settings
    ->get('original');

  // If the original settings don't exist, treat this as though it were new.
  if (!$original_settings) {
    $this
      ->onImportNew($event);
    return;
  }

  // @see \Drupal\content_translation\ContentTranslationManager::isEnabled()
  if ($settings
    ->getThirdPartySetting('content_translation', 'enabled', FALSE) && !$original_settings
    ->getThirdPartySetting('content_translation', 'enabled', FALSE)) {
    $this
      ->processSettings($settings);
  }
}