You are here

public function Update350::removeAudioFileLibraryFieldTranslatability in Lightning Media 8.3

Same name and namespace in other branches
  1. 8.4 modules/lightning_media_audio/src/Update/Update350.php \Drupal\lightning_media_audio\Update\Update350::removeAudioFileLibraryFieldTranslatability()

Makes field_media_in_library non-translatable.

@update

Parameters

\Symfony\Component\Console\Style\StyleInterface $io: The I/O handler.

File

modules/lightning_media_audio/src/Update/Update350.php, line 73

Class

Update350
Contains optional updates targeting Lightning Media Audio 3.5.0.

Namespace

Drupal\lightning_media_audio\Update

Code

public function removeAudioFileLibraryFieldTranslatability(StyleInterface $io) {

  /** @var \Drupal\field\Entity\FieldConfig $field */
  $field = $this->fieldStorage
    ->load('media.audio_file.field_media_in_library');
  if (empty($field)) {
    return;
  }
  $question = (string) $this
    ->t('Do you want to remove translatability for the @field field of @media_type media?', [
    '@field' => $field
      ->label(),
    '@media_type' => $this->mediaTypeStorage
      ->load('audio_file')
      ->label(),
  ]);
  if ($io
    ->confirm($question)) {
    $this->fieldStorage
      ->save($field
      ->setTranslatable(FALSE));
  }
}