Skip to content
Snippets Groups Projects
Select Git revision
  • be46986128cfa36608a353a363dd95312c67633b
  • annotation-on-video default protected
  • demo_ci
  • 3-upstream-01022023
  • master
  • gh3538-captions
  • 16-adapt-for-images-annot
  • 15-api-for-annotations-on-video
  • 15-annotations-on-videos
  • video_for_annotations
  • wip-1-annotations-on-videos
  • 9-videoviewer-tests
  • 9_wip_videotests
  • 6-fix-tests-and-ci
  • _fix_ci
  • wip-webpack-from-git
16 results

css.js

Blame
  • CapsuleController.php 2.28 KiB
    <?php
    
    namespace App\Controller;
    
    use App\Entity\Capsule;
    use App\Form\CreateCapsuleFormType;
    use App\LegacyHelper;
    use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
    use Symfony\Component\HttpFoundation\BinaryFileResponse;
    use Symfony\Component\HttpFoundation\File\Exception\FileException;
    use Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException;
    use Symfony\Component\HttpFoundation\File\File;
    use Symfony\Component\HttpFoundation\Request;
    use Symfony\Component\HttpFoundation\Response;
    use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
    use Symfony\Component\Routing\Annotation\Route;
    use Symfony\Component\Uid\Uuid;
    
    class CapsuleController extends AbstractController
    {
        /**
         * @Route("/my_capsules", name="capsule_list")
         * @Route("/", name="home")
         */
        public function index(Request $request): Response
        {
            return $this->render('capsule/index.html.twig', [
                'controller_name' => 'CapsuleController',
            ]);
        }
    
        /**
         * @Route("/create", name="create_capsule", methods={"POST"}, priority=-2)
         */
        public function new(Request $request): Response
        {
            $capsule = new Capsule();
            $form = $this->createForm(CreateCapsuleFormType::class, $capsule);
            $form->handleRequest($request);
    
            if ($form->isSubmitted() && $form->isValid()) {
                $new_date_time = new \DateTime();
                $capsule_name = $form->get('name')->getData();
                $video_url = $form->get('video_url')->getData();
                $preview_link = Uuid::v4();
                $edition_link = $preview_link . '/?p=edit';
    
                $capsule->setName($capsule_name);
                $capsule->setCreationAuthor($this->getUser());
                $capsule->setCreationDate($new_date_time);
                $capsule->setUpdatedDate($new_date_time);
                $capsule->setPreviewLink($preview_link);
                $capsule->setEditionLink($edition_link);
    
                $entityManager = $this->getDoctrine()->getManager();
                $entityManager->persist($capsule);
                $entityManager->flush();
    
                $this->redirectToRoute('create_project', [$capsule_name, $video_url]);
            }
    
            return $this->render('capsule/create.html.twig', [
                'capsuleCreationForm' => $form->createView()
                ]);
        }
    }