public function WebformEditorialController::videos in Webform 8.5
Returns webform videos editorial.
Return value
array A renderable array containing webform elements videos.
1 string reference to 'WebformEditorialController::videos'
- webform_editorial.routing.yml in modules/
webform_editorial/ webform_editorial.routing.yml - modules/webform_editorial/webform_editorial.routing.yml
File
- modules/
webform_editorial/ src/ Controller/ WebformEditorialController.php, line 239
Class
- WebformEditorialController
- Provides route responses for webform editorial.
Namespace
Drupal\webform_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);
}