src/xPDO/Transport/xPDOTransport.php
public static function _pack(& $xpdo, $filename, $path, $source) {
        $packed = false;
        $packResults = false;
        $errors = array();
        if ($xpdo->getOption(xPDOTransport::ARCHIVE_WITH, null, 0) != xPDOTransport::ARCHIVE_WITH_PCLZIP && class_exists('ZipArchive')) {
            if ($xpdo->getDebug() === true) {
                $xpdo->log(xPDO::LOG_LEVEL_DEBUG, "Using xPDOZip / native ZipArchive", null, __METHOD__, __FILE__, __LINE__);
            }
            $archive = new xPDOZip($xpdo, $filename, array(xPDOZip::CREATE => true, xPDOZip::OVERWRITE => true));
            if ($archive) {
                $packResults = $archive->pack("{$path}{$source}", array(xPDOZip::ZIP_TARGET => "{$source}/"));
                $archive->close();
                if (!$archive->hasError() && !empty($packResults)) {
                    $packed = true;
                } else {
                    $errors = $archive->getErrors();
                }
            }
        } elseif (class_exists('PclZip') || include(XPDO_CORE_PATH . 'Compression/pclzip.lib.php')) {
            $archive = new \PclZip($filename);
            if ($archive) {
                $packResults = $archive->create("{$path}{$source}", PCLZIP_OPT_REMOVE_PATH, "{$path}");
                if ($packResults) {
                    $packed = true;
                } else {
                    $errors = $archive->errorInfo($xpdo->getDebug() === true);
                }
            }
        }
        if (!$packed) {
            $xpdo->log(xPDO::LOG_LEVEL_ERROR, "Error packing {$path}{$source} to {$filename}: " . print_r($errors, true));
        }
        if ($xpdo->getDebug() === true) {
            $xpdo->log(xPDO::LOG_LEVEL_DEBUG, "Results of packing {$path}{$source} to {$filename}: " . print_r($packResults, true), null, __METHOD__, __FILE__, __LINE__);
        }
        return $packed;
    }
public static function _pack(& $xpdo, $filename, $path, $source) {
        $packed = false;
        $packResults = false;
        $errors = array();
        if ($xpdo->getOption(xPDOTransport::ARCHIVE_WITH, null, 0) != xPDOTransport::ARCHIVE_WITH_PCLZIP && class_exists('ZipArchive')) {
            if ($xpdo->getDebug() === true) {
                $xpdo->log(xPDO::LOG_LEVEL_DEBUG, "Using xPDOZip / native ZipArchive", null, __METHOD__, __FILE__, __LINE__);
            }
            $archive = new xPDOZip($xpdo, $filename, array(xPDOZip::CREATE => true, xPDOZip::OVERWRITE => true));
            if ($archive) {
                $packResults = $archive->pack("{$path}{$source}", array(xPDOZip::ZIP_TARGET => "{$source}/"));
                $archive->close();
                if (!$archive->hasError() && !empty($packResults)) {
                    $packed = true;
                } else {
                    $errors = $archive->getErrors();
                }
            }
        } elseif (class_exists('PclZip') || include(XPDO_CORE_PATH . 'Compression/pclzip.lib.php')) {
            $archive = new \PclZip($filename);
            if ($archive) {
                $packResults = $archive->create("{$path}{$source}", PCLZIP_OPT_REMOVE_PATH, "{$path}");
                if ($packResults) {
                    $packed = true;
                } else {
                    $errors = $archive->errorInfo($xpdo->getDebug() === true);
                }
            }
        }
        if (!$packed) {
            $xpdo->log(xPDO::LOG_LEVEL_ERROR, "Error packing {$path}{$source} to {$filename}: " . print_r($errors, true));
        }
        if ($xpdo->getDebug() === true) {
            $xpdo->log(xPDO::LOG_LEVEL_DEBUG, "Results of packing {$path}{$source} to {$filename}: " . print_r($packResults, true), null, __METHOD__, __FILE__, __LINE__);
        }
        return $packed;
    }
public static function _pack ( & $ xpdo , $ filename , $ path , $ source ) { $ packed = false ; $ packResults = false ; $ errors = array ( ) ; if ( $ xpdo -> getOption ( xPDOTransport :: ARCHIVE_WITH , null , 0 ) != xPDOTransport :: ARCHIVE_WITH_PCLZIP && class_exists ( 'ZipArchive' ) ) { if ( $ xpdo -> getDebug ( ) === true ) { $ xpdo -> log ( xPDO :: LOG_LEVEL_DEBUG , "Using xPDOZip / native ZipArchive" , null , __METHOD__ , __FILE__ , __LINE__ ) ; } $ archive = new xPDOZip ( $ xpdo , $ filename , array ( xPDOZip :: CREATE => true , xPDOZip :: OVERWRITE => true ) ) ; if ( $ archive ) { $ packResults = $ archive -> pack ( "{$path}{$source}" , array ( xPDOZip :: ZIP_TARGET => "{$source}/" ) ) ; $ archive -> close ( ) ; if ( ! $ archive -> hasError ( ) && ! empty ( $ packResults ) ) { $ packed = true ; } else { $ errors = $ archive -> getErrors ( ) ; } } } elseif ( class_exists ( 'PclZip' ) || include ( XPDO_CORE_PATH . 'Compression/pclzip.lib.php' ) ) { $ archive = new \ PclZip ( $ filename ) ; if ( $ archive ) { $ packResults = $ archive -> create ( "{$path}{$source}" , PCLZIP_OPT_REMOVE_PATH , "{$path}" ) ; if ( $ packResults ) { $ packed = true ; } else { $ errors = $ archive -> errorInfo ( $ xpdo -> getDebug ( ) === true ) ; } } } if ( ! $ packed ) { $ xpdo -> log ( xPDO :: LOG_LEVEL_ERROR , "Error packing {$path}{$source} to {$filename}: " . print_r ( $ errors , true ) ) ; } if ( $ xpdo -> getDebug ( ) === true ) { $ xpdo -> log ( xPDO :: LOG_LEVEL_DEBUG , "Results of packing {$path}{$source} to {$filename}: " . print_r ( $ packResults , true ) , null , __METHOD__ , __FILE__ , __LINE__ ) ; } return $ packed ; }
Pack the resources from path relative to source into an archive with filename.

@uses compression.xPDOZip OR compression.PclZip
@todo Refactor this to be implemented in a service class external to xPDOTransport.

@param xPDO &$xpdo A reference to an xPDO instance.
@param string $filename A valid zip archive filename.
@param string $path An absolute file system path location of the resources to pack.
@param string $source A relative portion of path to include in the archive.
@return boolean True if packed successfully.
Pack the resources from path relative to source into an archive with filename .