public function WebformTestEditorialController::videos in Webform 6.x
Returns webform videos editorial.
Return value
array A renderable array containing webform elements videos.
1 string reference to 'WebformTestEditorialController::videos'
- webform_test_editorial.routing.yml in tests/
modules/ webform_test_editorial/ webform_test_editorial.routing.yml - tests/modules/webform_test_editorial/webform_test_editorial.routing.yml
File
- tests/
modules/ webform_test_editorial/ src/ Controller/ WebformTestEditorialController.php, line 208
Class
- WebformTestEditorialController
- Provides route responses for webform editorial.
Namespace
Drupal\webform_test_editorial\ControllerCode
public function videos() {
// Header.
$header = [
[
'data' => $this
->t('Name'),
'width' => '10%',
],
[
'data' => $this
->t('Title'),
'width' => '20%',
],
[
'data' => $this
->t('Content'),
'width' => '50%',
],
[
'data' => $this
->t('Video/Slides'),
'width' => '20%',
],
];
// Rows.
$rows = [];
$videos = $this->helpManager
->getVideo();
foreach ($videos as $name => $info) {
// @see https://stackoverflow.com/questions/2068344/how-do-i-get-a-youtube-video-thumbnail-from-the-youtube-api
$image = Markup::create('<img width="180" src="https://img.youtube.com/vi/' . $info['youtube_id'] . '/0.jpg" />');
$video = Link::fromTextAndUrl($image, Url::fromUri('https://www.youtube.com/watch', [
'query' => [
'v' => $info['youtube_id'],
],
]))
->toString();
$slides = Link::fromTextAndUrl($this
->t('Slides'), Url::fromUri('https://docs.google.com/presentation/d/' . $info['presentation_id']))
->toString();
$rows[] = [
'data' => [
[
'data' => '<b>' . $name . '</b>' . (!empty($info['hidden']) ? '<br/>[' . $this
->t('hidden') . ']' : ''),
],
[
'data' => $info['title'],
],
[
'data' => $info['content'],
],
[
'data' => $video . '<br/>' . $slides,
],
],
];
}
$build = $this
->buildTable('Webform: Videos editorial', $header, $rows);
return $this
->response($build);
}