final class Update240 in Lightning Media 8.3
Same name in this branch
- 8.3 src/Update/Update240.php \Drupal\lightning_media\Update\Update240
- 8.3 modules/lightning_media_video/src/Update/Update240.php \Drupal\lightning_media_video\Update\Update240
Same name and namespace in other branches
- 8.4 src/Update/Update240.php \Drupal\lightning_media\Update\Update240
- 8.2 src/Update/Update240.php \Drupal\lightning_media\Update\Update240
Contains optional updates targeting Lightning Media 2.4.0.
Plugin annotation
@Update("2.4.0");
Hierarchy
- class \Drupal\lightning_media\Update\Update240 implements ContainerInjectionInterface
Expanded class hierarchy of Update240
File
- src/
Update/ Update240.php, line 15
Namespace
Drupal\lightning_media\UpdateView source
final class Update240 implements ContainerInjectionInterface {
/**
* The field config storage.
*
* @var \Drupal\Core\Entity\EntityStorageInterface
*/
private $fieldConfigStorage;
/**
* The module installer.
*
* @var \Drupal\Core\Extension\ModuleInstallerInterface
*/
protected $moduleInstaller;
/**
* Update240 constructor.
*
* @param \Drupal\Core\Entity\EntityStorageInterface $field_config_storage
* The field config storage.
* @param \Drupal\Core\Extension\ModuleInstallerInterface $module_installer
* The module installer service.
*/
public function __construct(EntityStorageInterface $field_config_storage, ModuleInstallerInterface $module_installer) {
$this->fieldConfigStorage = $field_config_storage;
$this->moduleInstaller = $module_installer;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static($container
->get('entity_type.manager')
->getStorage('field_config'), $container
->get('module_installer'));
}
/**
* Renames the "Save to my media library" field of all media types.
*
* @update
*
* @ask Do you want to rename the "Save to my media library" field of all
* media types to "Show in media library"?
*/
public function renameSaveToMyMediaLibrary() {
/** @var \Drupal\field\Entity\FieldConfig[] $field_configs */
$field_configs = $this->fieldConfigStorage
->loadByProperties([
'field_name' => 'field_media_in_library',
'entity_type' => 'media',
]);
foreach ($field_configs as $field_config) {
$field_config
->setLabel('Show in media library')
->setSettings([
'on_label' => 'Shown in media library',
'off_label' => 'Hidden in media library',
])
->save();
}
}
/**
* Enables Audio file media.
*
* @update
*
* @ask Do you want to install "Audio file" media?
*/
public function enableAudioFileMedia() {
$this->moduleInstaller
->install([
'lightning_media_audio',
]);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
Update240:: |
private | property | The field config storage. | |
Update240:: |
protected | property | The module installer. | |
Update240:: |
public static | function |
Instantiates a new instance of this class. Overrides ContainerInjectionInterface:: |
|
Update240:: |
public | function | Enables Audio file media. | |
Update240:: |
public | function | Renames the "Save to my media library" field of all media types. | |
Update240:: |
public | function | Update240 constructor. |