-
Notifications
You must be signed in to change notification settings - Fork 0
/
media_oembed_example.install
53 lines (47 loc) · 1.32 KB
/
media_oembed_example.install
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
/**
* @file
* This module provides install, uninstall, and update functions.
*/
use Drupal\Core\Url;
/**
* Implements hook_install().
*/
function media_oembed_example_install() {
$oembed_storage = Drupal::entityTypeManager()->getStorage('oembed_provider');
$entity = $oembed_storage
->getQuery()
->condition('id', 'media_oembed_example_provider')
->execute();
if (empty($entity)) {
$oembed_storage->create([
'id' => 'media_oembed_example_provider',
'label' => 'oEmbed Example Provider',
'provider_url' => 'https://video.school.edu',
'endpoints' => [
[
'url' => Url::fromRoute('media_oembed_example.media_route', [], ['absolute' => TRUE])->toString(FALSE),
'schemes' => [
'https://video.school.edu/path1*',
'https://video.school.edu/path2.ext*',
],
'discovery' => FALSE,
'formats' => [
'json' => TRUE,
'xml' => FALSE,
],
]
],
])->save();
}
}
/**
* Implements hook_uninstall().
*/
function media_oembed_example_uninstall() {
$oembed_storage = Drupal::entityTypeManager()->getStorage('oembed_provider');
$entity = $oembed_storage->load('media_oembed_example_provider');
if (!empty($entity)) {
$oembed_storage->delete([$entity]);
}
}