final class Update350 in Lightning Media 8.4
Same name in this branch
- 8.4 modules/lightning_media_audio/src/Update/Update350.php \Drupal\lightning_media_audio\Update\Update350
- 8.4 modules/lightning_media_video/src/Update/Update350.php \Drupal\lightning_media_video\Update\Update350
Same name and namespace in other branches
- 8.3 modules/lightning_media_audio/src/Update/Update350.php \Drupal\lightning_media_audio\Update\Update350
Contains optional updates targeting Lightning Media Audio 3.5.0.
Plugin annotation
@Update("3.5.0");
Hierarchy
- class \Drupal\lightning_media_audio\Update\Update350 implements ContainerInjectionInterface uses StringTranslationTrait
Expanded class hierarchy of Update350
1 file declares its use of Update350
- Update350Test.php in modules/
lightning_media_audio/ tests/ src/ Kernel/ Update/ Update350Test.php
File
- modules/
lightning_media_audio/ src/ Update/ Update350.php, line 17
Namespace
Drupal\lightning_media_audio\UpdateView source
final class Update350 implements ContainerInjectionInterface {
use StringTranslationTrait;
/**
* The media type entity storage handler.
*
* @var \Drupal\Core\Entity\EntityStorageInterface
*/
private $mediaTypeStorage;
/**
* The field config entity storage handler.
*
* @var \Drupal\Core\Entity\EntityStorageInterface
*/
private $fieldStorage;
/**
* Update350 constructor.
*
* @param \Drupal\Core\Entity\EntityStorageInterface $media_type_storage
* The media type entity storage handler.
* @param \Drupal\Core\Entity\EntityStorageInterface $field_storage
* The field config entity storage handler.
* @param \Drupal\Core\StringTranslation\TranslationInterface $translation
* (optional) The string translation service.
*/
public function __construct(EntityStorageInterface $media_type_storage, EntityStorageInterface $field_storage, TranslationInterface $translation = NULL) {
$this->mediaTypeStorage = $media_type_storage;
$this->fieldStorage = $field_storage;
if ($translation) {
$this
->setStringTranslation($translation);
}
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static($container
->get('entity_type.manager')
->getStorage('media_type'), $container
->get('entity_type.manager')
->getStorage('field_config'), $container
->get('string_translation'));
}
/**
* Makes field_media_in_library non-translatable.
*
* @param \Symfony\Component\Console\Style\StyleInterface $io
* The I/O handler.
*
* @update
*/
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));
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. | |
Update350:: |
private | property | The field config entity storage handler. | |
Update350:: |
private | property | The media type entity storage handler. | |
Update350:: |
public static | function |
Instantiates a new instance of this class. Overrides ContainerInjectionInterface:: |
|
Update350:: |
public | function | Makes field_media_in_library non-translatable. | |
Update350:: |
public | function | Update350 constructor. |