oembed_providers.install in oEmbed Providers 2.x
Same filename and directory in other branches
This module provides install, uninstall, and update functions.
File
oembed_providers.installView source
<?php
/**
* @file
* This module provides install, uninstall, and update functions.
*/
use Drupal\oembed_providers\Entity\ProviderBucket;
/**
* Implements hook_install().
*/
function oembed_providers_install() {
// Use $is_syncing parameter when Drupal 8.8 reaches EOL.
// https://www.drupal.org/node/3098920.
if (!\Drupal::isConfigSyncing()) {
\Drupal::messenger()
->addWarning(t('The <em>oEmbed Providers</em> module now manages oEmbed providers. Allowed oEmbed providers must be designated. <a href="@url">Configure <em>Allowed Providers</em> settings</a>', [
'@url' => '/admin/config/media/oembed-providers/allowed-providers',
]));
}
}
/**
* Convert 1.x.x allowed providers into "video" bucket.
*/
function oembed_providers_update_8201() {
$config = \Drupal::service('config.factory')
->getEditable('oembed_providers.settings');
$providers = $config
->get('allowed_providers');
$config
->clear('allowed_providers');
$config
->save();
ProviderBucket::create([
'id' => 'video',
'label' => 'Remote Video',
'providers' => $providers,
])
->save();
return t('Global "Allowed Providers" were migrated to a newly created "Remote Video (video)" provider bucket.');
}
/**
* Install oEmbed provider bucket entity type.
*/
function oembed_providers_update_8202() {
\Drupal::entityTypeManager()
->clearCachedDefinitions();
$entity_type = \Drupal::entityTypeManager()
->getDefinition('oembed_provider_bucket');
\Drupal::entityDefinitionUpdateManager()
->installEntityType($entity_type);
}
Functions
Name | Description |
---|---|
oembed_providers_install | Implements hook_install(). |
oembed_providers_update_8201 | Convert 1.x.x allowed providers into "video" bucket. |
oembed_providers_update_8202 | Install oEmbed provider bucket entity type. |