src/Utils/DebugUtil.php
/**
     * The method to create the debug dump with all artefacts and reports.
     *
     * @param string $serial The serial to create the dump for
     *
     * @return string $filename The name of the dumpfile
     * @throws \InvalidArgumentException Is thrown, if the passed serial has no matching import to create the dump for
     */
The method to create the debug dump with all artefacts and reports.
@param string $serial The serial to create the dump for

@return string $filename The name of the dumpfile
@throws \InvalidArgumentException Is thrown, if the passed serial has no matching import to create the dump for
The method to create the debug dump with all artefacts and reports . @param string $serial The serial to create the dump for @return string $filename The name of the dumpfile @throws \ InvalidArgumentException Is thrown if the passed serial has no matching import to create the dump for
public function createDump(string $serial) : string
    {
        $dumpFile = null;
        $status = $this->getRegistryProcessor()->getAttribute(RegistryKeys::STATUS);
        clearstatcache();
        if (!is_dir($sourceDir = $status[RegistryKeys::SOURCE_DIRECTORY])) {
            throw new \Exception(sprintf('Configured source directory %s is not available!', $sourceDir));
        }
        $dumpFile = new \ZipArchive();
        $dumpFile->open($dumpFilename = sprintf('%s/%s.zip', sys_get_temp_dir(), $serial), \ZipArchive::CREATE);
        $fileIterator = new \FilesystemIterator($sourceDir);
        foreach ($fileIterator as $filename) {
            if ($filename->isFile()) {
                $dumpFile->addFile($filename, basename($filename));
            }
        }
        $dumpFile->close();
        $this->getSystemLogger()->info(sprintf('Successfully created dump "%s" with artefacts for serial "%s"', $dumpFilename, $serial));
        return $dumpFilename;
    }
public function createDump ( string $ serial ) : string { $ dumpFile = null ; $ status = $ this -> getRegistryProcessor ( ) -> getAttribute ( RegistryKeys :: STATUS ) ; clearstatcache ( ) ; if ( ! is_dir ( $ sourceDir = $ status [ RegistryKeys :: SOURCE_DIRECTORY ] ) ) { throw new \ Exception ( sprintf ( 'Configured source directory %s is not available!' , $ sourceDir ) ) ; } $ dumpFile = new \ ZipArchive ( ) ; $ dumpFile -> open ( $ dumpFilename = sprintf ( '%s/%s.zip' , sys_get_temp_dir ( ) , $ serial ) , \ ZipArchive :: CREATE ) ; $ fileIterator = new \ FilesystemIterator ( $ sourceDir ) ; foreach ( $ fileIterator as $ filename ) { if ( $ filename -> isFile ( ) ) { $ dumpFile -> addFile ( $ filename , basename ( $ filename ) ) ; } } $ dumpFile -> close ( ) ; $ this -> getSystemLogger ( ) -> info ( sprintf ( 'Successfully created dump "%s" with artefacts for serial "%s"' , $ dumpFilename , $ serial ) ) ; return $ dumpFilename ; }
The method to create the debug dump with all artefacts and reports.
The method to create the debug dump with all artefacts and reports .
// initialize the dump filename // load the actual status // clear the filecache // query whether or not the configured source directory is available // create the ZIP archive // init file iterator on source directory // iterate through all files and add them to the ZIP archive /** @var \SplFileInfo $filename */ // save the ZIP archive // log a message that the dump has successfully been created // return the filename of the dump