public function guessRootFile(UploadedFile $file, Workspace $workspace)
    {
        $zipPath = $this->container->getParameter('claroline.param.uploads_directory').DIRECTORY_SEPARATOR.'webresource'.DIRECTORY_SEPARATOR.$workspace->getUuid().DIRECTORY_SEPARATOR;

        if (!$this->getZip()->open($file)) {
            throw new \Exception('Can not open archive file.');
        }

        // Try to locate usual default HTML files to avoid unzip archive and scan directory tree
        foreach ($this->defaultIndexFiles as $html) {
            if (is_numeric($this->getZip()->locateName($html))) {
                return $html;
            }
        }

        // No default index file found => scan archive
        // Extract content into tmp dir
        $tmpDir = $zipPath.'tmp/';
        if (!$tmpDir) {
            mkdir($zipPath.'tmp/', 0777, true);
        }
        $this->getZip()->extractTo($tmpDir);
        $this->getZip()->close();

        // Search for root file
        $htmlFiles = $this->getHTMLFiles($tmpDir);

        // Remove tmp data
        $this->unzipDelete($tmpDir);

        // Only one file
        if (1 === count($htmlFiles)) {
            return array_shift($htmlFiles);
        }

        return;
    }
public function guessRootFile(UploadedFile $file, Workspace $workspace)
    {
        $zipPath = $this->container->getParameter('claroline.param.uploads_directory').DIRECTORY_SEPARATOR.'webresource'.DIRECTORY_SEPARATOR.$workspace->getUuid().DIRECTORY_SEPARATOR;

        if (!$this->getZip()->open($file)) {
            throw new \Exception('Can not open archive file.');
        }

        // Try to locate usual default HTML files to avoid unzip archive and scan directory tree
        foreach ($this->defaultIndexFiles as $html) {
            if (is_numeric($this->getZip()->locateName($html))) {
                return $html;
            }
        }

        // No default index file found => scan archive
        // Extract content into tmp dir
        $tmpDir = $zipPath.'tmp/';
        if (!$tmpDir) {
            mkdir($zipPath.'tmp/', 0777, true);
        }
        $this->getZip()->extractTo($tmpDir);
        $this->getZip()->close();

        // Search for root file
        $htmlFiles = $this->getHTMLFiles($tmpDir);

        // Remove tmp data
        $this->unzipDelete($tmpDir);

        // Only one file
        if (1 === count($htmlFiles)) {
            return array_shift($htmlFiles);
        }

        return;
    }
public function guessRootFile ( UploadedFile $ file , Workspace $ workspace ) { $ zipPath = $ this -> container -> getParameter ( 'claroline.param.uploads_directory' ) . DIRECTORY_SEPARATOR . 'webresource' . DIRECTORY_SEPARATOR . $ workspace -> getUuid ( ) . DIRECTORY_SEPARATOR ; if ( ! $ this -> getZip ( ) -> open ( $ file ) ) { throw new \ Exception ( 'Can not open archive file.' ) ; } // Try to locate usual default HTML files to avoid unzip archive and scan directory tree foreach ( $ this -> defaultIndexFiles as $ html ) { if ( is_numeric ( $ this -> getZip ( ) -> locateName ( $ html ) ) ) { return $ html ; } } // No default index file found => scan archive // Extract content into tmp dir $ tmpDir = $ zipPath . 'tmp/' ; if ( ! $ tmpDir ) { mkdir ( $ zipPath . 'tmp/' , 0777 , true ) ; } $ this -> getZip ( ) -> extractTo ( $ tmpDir ) ; $ this -> getZip ( ) -> close ( ) ; // Search for root file $ htmlFiles = $ this -> getHTMLFiles ( $ tmpDir ) ; // Remove tmp data $ this -> unzipDelete ( $ tmpDir ) ; // Only one file if ( 1 === count ( $ htmlFiles ) ) { return array_shift ( $ htmlFiles ) ; } return ; }
Try to retrieve root file of the WebResource from the zip archive.

@param Workspace    $workspace
@param UploadedFile $file

@return string

@throws \Exception
Try to retrieve root file of the WebResource from the zip archive .