You are here

public function ContentHelpController::video in Content Synchronization 8

Same name and namespace in other branches
  1. 8.2 src/Controller/ContentHelpController.php \Drupal\content_sync\Controller\ContentHelpController::video()
  2. 3.0.x src/Controller/ContentHelpController.php \Drupal\content_sync\Controller\ContentHelpController::video()

Returns dedicated help video page.

Parameters

\Symfony\Component\HttpFoundation\Request $request: The current request.

string $id: The video id.

Return value

array A renderable array containing a help video player page.

File

src/Controller/ContentHelpController.php, line 74

Class

ContentHelpController
Provides route responses for content_sync help.

Namespace

Drupal\content_sync\Controller

Code

public function video(Request $request, $id) {
  $id = str_replace('-', '_', $id);
  $video = $this->helpManager
    ->getVideo($id);
  if (!$video) {
    throw new NotFoundHttpException();
  }
  $build = [];
  if (is_array($video['content'])) {
    $build['content'] = $video['content'];
  }
  else {
    $build['content'] = [
      '#markup' => $video['content'],
    ];
  }
  if ($video['youtube_id']) {
    $build['video'] = [
      '#theme' => 'content_sync_help_video_youtube',
      '#youtube_id' => $video['youtube_id'],
    ];
  }
  return $build;
}