src/Utils/DebugUtil.php
/**
     * The method to extract an archive that has already been created by a previous
     * import back into the source directory.
     *
     * @param string $serial The serial of the archive to extract
     *
     * @return void
     * @throws \Exception Is thrown, if the archive can not be extracted back into the source directory
     */
The method to extract an archive that has already been created by a previous
import back into the source directory.

@param string $serial The serial of the archive to extract

@return void
@throws \Exception Is thrown, if the archive can not be extracted back into the source directory
The method to extract an archive that has already been created by a previous import back into the source directory . @param string $serial The serial of the archive to extract @return void @throws \ Exception Is thrown if the archive can not be extracted back into the source directory
public function extractArchive(string $serial) : void
    {
        clearstatcache();
        $status = $this->getRegistryProcessor()->getAttribute(RegistryKeys::STATUS);
        if (isset($status[RegistryKeys::SOURCE_DIRECTORY])) {
            $sourceDir = $status[RegistryKeys::SOURCE_DIRECTORY];
        } else {
            throw new \Exception('Source directory is not available!');
        }
        $archiveDir = $this->getConfiguration()->getArchiveDir();
        if ($archiveDir === null) {
            $archiveDir = sprintf('var/import_history');
        }
        $zip = new \ZipArchive();
        $archiveFile = sprintf('%s/%s.zip', $archiveDir, $serial);
        if (is_dir($sourceDir)) {
            $this->getSystemLogger()->warning(
                sprintf(
                    'Won\'t extract artefacts of "%s" for serial "%s" to directory "%s", because directory already exists',
                    $archiveFile,
                    $serial,
                    $sourceDir
                )
            );
            return;
        }
        if (is_file($archiveFile)) {
            if ($zip->open($archiveFile) === true) {
                $zip->extractTo($sourceDir);
                $zip->close();
            } else {
                throw new \Exception(sprintf('Can\'t extract archive "%s" back into source directory', $archiveFile));
            }
        } else {
            $this->getSystemLogger()->debug(sprintf('"%s" is not available and can not be extracted therefore', $archiveFile));
        }
        $this->getSystemLogger()->info(sprintf('Successfully extracted artefacts for serial "%s" to directory %s', $serial, $sourceDir));
    }
public function extractArchive ( string $ serial ) : void { clearstatcache ( ) ; $ status = $ this -> getRegistryProcessor ( ) -> getAttribute ( RegistryKeys :: STATUS ) ; if ( isset ( $ status [ RegistryKeys :: SOURCE_DIRECTORY ] ) ) { $ sourceDir = $ status [ RegistryKeys :: SOURCE_DIRECTORY ] ; } else { throw new \ Exception ( 'Source directory is not available!' ) ; } $ archiveDir = $ this -> getConfiguration ( ) -> getArchiveDir ( ) ; if ( $ archiveDir === null ) { $ archiveDir = sprintf ( 'var/import_history' ) ; } $ zip = new \ ZipArchive ( ) ; $ archiveFile = sprintf ( '%s/%s.zip' , $ archiveDir , $ serial ) ; if ( is_dir ( $ sourceDir ) ) { $ this -> getSystemLogger ( ) -> warning ( sprintf ( 'Won\'t extract artefacts of "%s" for serial "%s" to directory "%s", because directory already exists' , $ archiveFile , $ serial , $ sourceDir ) ) ; return ; } if ( is_file ( $ archiveFile ) ) { if ( $ zip -> open ( $ archiveFile ) === true ) { $ zip -> extractTo ( $ sourceDir ) ; $ zip -> close ( ) ; } else { throw new \ Exception ( sprintf ( 'Can\'t extract archive "%s" back into source directory' , $ archiveFile ) ) ; } } else { $ this -> getSystemLogger ( ) -> debug ( sprintf ( '"%s" is not available and can not be extracted therefore' , $ archiveFile ) ) ; } $ this -> getSystemLogger ( ) -> info ( sprintf ( 'Successfully extracted artefacts for serial "%s" to directory %s' , $ serial , $ sourceDir ) ) ; }
The method to extract an archive that has already been created by a previous
 import back into the source directory.
The method to extract an archive that has already been created by a previous import back into the source directory .
// clear the filecache // load the actual status // query whether or not the configured source directory is available // try to load the archive directory // query whether or not the specified archive directory already exists // initialize the ZIP instance // prepare the archive filename // query whether or not the directory already exists // log a warning and stop extracting the files // stop processing the file extraction of the ZIP file // try to open and extract the ZIP archive // log a message that the file has successfully been extracted