/**
  * Render password protected page
  *
  * @param SquarespacePage $page
  * @return array
  *
  * @Route(
  *      path = "/course/{code}/sq-page/render/{id}",
  *      name = "beloop_render_module_squarespace_page",
  *      methods = {"GET"}
  * )
  *
  * @EntityAnnotation(
  *      class = {
  *          "factory" = "beloop.factory.squarespace_page",
  *          "method" = "create",
  *          "static" = false
  *      },
  *      name = "page",
  *      mapping = {
  *          "id" = "~id~"
  *      },
  *      mappingFallback = true
  * )
  */
 public function renderSquarespacePageAction(SquarespacePage $page)
 {
     $user = $this->getUser();
     $course = $page->getCourse();
     // Extra checks if user is not TEACHER or ADMIN
     if (false === $this->get('security.authorization_checker')->isGranted('ROLE_TEACHER') && false === $course->isDemo()) {
         $userEnrolled = $course->getEnrolledUsers()->contains($user);
         if (!$userEnrolled) {
             throw $this->createNotFoundException('The course does not exist');
         }
         if (!$page->isAvailable()) {
             throw $this->createNotFoundException('The course does not exist');
         }
     }
     $content = $this->get('beloop.squarespace.page_renderer')->render($page);
     return new Response($content);
 }