/** * Get an existing {@link xPDOTransport} instance. */ public static function retrieve(&$xpdo, $source, $target, $state = xPDOTransport::STATE_PACKED) { $instance = null; $signature = basename($source, '.transport.zip'); if (file_exists($source)) { if (is_writable($target)) { $manifest = xPDOTransport::unpack($xpdo, $source, $target, $state); if ($manifest) { $instance = new xPDOTransport($xpdo, $signature, $target); if (!$instance) { $xpdo->log(xPDO::LOG_LEVEL_ERROR, "Could not instantiate a valid xPDOTransport object from the package {$source} to {$target}. SIG: {$signature} MANIFEST: " . print_r($manifest, 1)); } $manifestVersion = xPDOTransport::manifestVersion($manifest); switch ($manifestVersion) { case '0.1': $instance->vehicles = xPDOTransport::_convertManifestVer1_1(xPDOTransport::_convertManifestVer1_0($manifest)); case '0.2': $instance->vehicles = xPDOTransport::_convertManifestVer1_1(xPDOTransport::_convertManifestVer1_0($manifest[xPDOTransport::MANIFEST_VEHICLES])); $instance->attributes = $manifest[xPDOTransport::MANIFEST_ATTRIBUTES]; break; case '1.0': $instance->vehicles = xPDOTransport::_convertManifestVer1_1($manifest[xPDOTransport::MANIFEST_VEHICLES]); $instance->attributes = $manifest[xPDOTransport::MANIFEST_ATTRIBUTES]; break; default: $instance->vehicles = $manifest[xPDOTransport::MANIFEST_VEHICLES]; $instance->attributes = $manifest[xPDOTransport::MANIFEST_ATTRIBUTES]; break; } } else { $xpdo->log(xPDO::LOG_LEVEL_ERROR, "Could not unpack package {$source} to {$target}. SIG: {$signature}"); } } else { $xpdo->log(xPDO::LOG_LEVEL_ERROR, "Could not unpack package: {$target} is not writable. SIG: {$signature}"); } } else { $xpdo->log(xPDO::LOG_LEVEL_ERROR, "Package {$source} not found. SIG: {$signature}"); } return $instance; }