Skip to content
Snippets Groups Projects
Select Git revision
  • 59b4e3ea4957bce9f88153dc83d3a6ee7725d86d
  • 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

VideoViewer.test.js

Blame
  • ProjectController.php 7.45 KiB
    <?php
    
    namespace App\Controller;
    
    use App\Entity\Capsule;
    use App\Entity\PendingEditorInvitation;
    use App\Exception\ZipArchiveNotOpeningException;
    use App\Form\EditVideoUrlFormType;
    use App\Form\RemoveEditorFormType;
    use App\Repository\CapsuleRepository;
    use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
    use Symfony\Bundle\FrameworkBundle\Translation\Translator;
    use Symfony\Component\Config\Util\Exception\XmlParsingException;
    use Symfony\Component\Filesystem\Exception\FileNotFoundException;
    use Symfony\Component\Filesystem\Filesystem;
    use Symfony\Component\HttpFoundation\File\Exception\FileException;
    use Symfony\Component\HttpFoundation\Request;
    use Symfony\Component\HttpFoundation\Response;
    use Symfony\Component\Routing\Annotation\Route;
    use Symfony\Contracts\Translation\TranslatorInterface;
    use ZipArchive;
    
    class ProjectController extends AbstractController
    {
        private TranslatorInterface $translator;
    
        public function __construct(TranslatorInterface $translator)
        {
            $this->translator = $translator;
        }
    
        /**
         * @Route("/project/create", name="create_project", methods={"POST"})
         * @throws ZipArchiveNotOpeningException
         */
        public function create(
            Capsule $capsule,
            string $video_url
        ): Response {
            chdir('../legacy/');
    
            $capsule_name = $capsule->getName();
            $capsule_directory = $capsule->getLinkPath();
    
            if (file_exists($capsule_directory)) {
                $this->addFlash(
                    'warning',
                    $this->translator->trans(
                        'project.already_exists',
                        [
                        'capsule_name' => $capsule_name
                        ]
                    )
                );
    
                return $this->redirectToRoute('capsule_list');
            }
    
            $this->extractZipArchiveInNewCapsuleDirectory($capsule_directory);
    
            $this->setVideoUrlNodeAttributeInXMLProjectFile($capsule_directory, $video_url);
    
            $this->createOrUpdatePasswordFile($capsule_directory, $capsule->getPassword());
    
            $this->addFlash(
                'success',
                $this->translator->trans(
                    'capsule.created_success',
                    [
                        'capsule_name' => $capsule_name