xpdo/transport/xpdotransport.class.php

Classes 
package
xpdo
subpackage
transport
Classes
xPDOTransport

Description

Represents a transportable package of related data and other resources.

\xPDOTransport

package
xpdo
subpackage
transport
Constants
ABORT_INSTALL_ON_VEHICLE_FAIL
ACTION_INSTALL
ACTION_UNINSTALL
ACTION_UPGRADE
ARCHIVE_WITH
ARCHIVE_WITH_DEFAULT
ARCHIVE_WITH_PCLZIP
ARCHIVE_WITH_ZIPARCHIVE
INSTALL_FILES
MANIFEST_ATTRIBUTES
MANIFEST_VEHICLES
MANIFEST_VERSION
NATIVE_KEY
PACKAGE_ACTION
PACKAGE_STATE
PREEXISTING_MODE
PRESERVE_KEYS
PRESERVE_PREEXISTING
RELATED_OBJECTS
RELATED_OBJECT_ATTRIBUTES
REMOVE_PREEXISTING
RESOLVE_FILES
RESOLVE_FILES_REMOVE
RESOLVE_PHP
RESTORE_PREEXISTING
STATE_INSTALLED
STATE_PACKED
STATE_UNPACKED
UNINSTALL_FILES
UNINSTALL_OBJECT
UNIQUE_KEY
UPDATE_OBJECT
Properties
$_preserved
$attributes
$manifestVersion
$path
$signature
$state
$vehicles
$xpdo
Methods
__construct
_convertManifestVer1_0
_convertManifestVer1_1
_pack
_unpack
get
getAttribute
install
loadPreserved
manifestVersion
pack
put
registerVehicle
retrieve
setAttribute
store
uninstall
unpack
writeManifest
writePreserved

Description

Represents xPDOObject and related data in a serialized format for exchange.

Constants

PRESERVE_KEYS

 PRESERVE_KEYS = 'preserve_keys'

Details

value
preserve_keys

NATIVE_KEY

 NATIVE_KEY = 'native_key'

Details

value
native_key

UNIQUE_KEY

 UNIQUE_KEY = 'unique_key'

Details

value
unique_key

UPDATE_OBJECT

 UPDATE_OBJECT = 'update_object'

Details

value
update_object

RESOLVE_FILES

 RESOLVE_FILES = 'resolve_files'

Details

value
resolve_files

RESOLVE_FILES_REMOVE

 RESOLVE_FILES_REMOVE = 'resolve_files_remove'

Details

value
resolve_files_remove

RESOLVE_PHP

 RESOLVE_PHP = 'resolve_php'

Details

value
resolve_php

PACKAGE_ACTION

 PACKAGE_ACTION = 'package_action'

Details

value
package_action

PACKAGE_STATE

 PACKAGE_STATE = 'package_state'

Details

value
package_state

RELATED_OBJECTS

 RELATED_OBJECTS = 'related_objects'

Details

value
related_objects

RELATED_OBJECT_ATTRIBUTES

 RELATED_OBJECT_ATTRIBUTES = 'related_object_attributes'

Details

value
related_object_attributes

MANIFEST_ATTRIBUTES

 MANIFEST_ATTRIBUTES = 'manifest-attributes'

Details

value
manifest-attributes

MANIFEST_VEHICLES

 MANIFEST_VEHICLES = 'manifest-vehicles'

Details

value
manifest-vehicles

MANIFEST_VERSION

 MANIFEST_VERSION = 'manifest-version'

Details

value
manifest-version

PREEXISTING_MODE

 PREEXISTING_MODE = 'preexisting_mode'

Details

value
preexisting_mode

INSTALL_FILES

 INSTALL_FILES = 'install_files'

Details

value
install_files

UNINSTALL_FILES

 UNINSTALL_FILES = 'uninstall_files'

Details

value
uninstall_files

UNINSTALL_OBJECT

 UNINSTALL_OBJECT = 'uninstall_object'

Details

value
uninstall_object

ARCHIVE_WITH

 ARCHIVE_WITH = 'archive_with'

Details

value
archive_with

ABORT_INSTALL_ON_VEHICLE_FAIL

 ABORT_INSTALL_ON_VEHICLE_FAIL = 'abort_install_on_vehicle_fail'

Details

value
abort_install_on_vehicle_fail

PRESERVE_PREEXISTING

integer PRESERVE_PREEXISTING = '0'

Indicates how pre-existing objects are treated on install/uninstall.

Details

value
0
integer

REMOVE_PREEXISTING

 REMOVE_PREEXISTING = '1'

Details

value
1

RESTORE_PREEXISTING

 RESTORE_PREEXISTING = '2'

Details

value
2

STATE_UNPACKED

integer STATE_UNPACKED = '0'

Indicates the physical state of the package.

Details

value
0
integer

STATE_PACKED

 STATE_PACKED = '1'

Details

value
1

STATE_INSTALLED

 STATE_INSTALLED = '2'

Details

value
2

ACTION_INSTALL

integer ACTION_INSTALL = '0'

Indicates an action that can be performed on the package.

Details

value
0
integer

ACTION_UPGRADE

 ACTION_UPGRADE = '1'

Details

value
1

ACTION_UNINSTALL

 ACTION_UNINSTALL = '2'

Details

value
2

ARCHIVE_WITH_DEFAULT

integer ARCHIVE_WITH_DEFAULT = '0'

Indicates which archiving tool to use for pack()'ing and unpack()'ing the transport.

Details

value
0
integer

ARCHIVE_WITH_PCLZIP

 ARCHIVE_WITH_PCLZIP = '1'

Details

value
1

ARCHIVE_WITH_ZIPARCHIVE

 ARCHIVE_WITH_ZIPARCHIVE = '2'

Details

value
2

Properties

$_preserved

array $_preserved = 'array'

An map of preserved objects from an install used by uninstall.

Details

array
visibility
public
default
array
final
false
static
false

$attributes

array $attributes = 'array'

Stores various attributes about the transport package.

Details

array
visibility
public
default
array
final
false
static
false

$manifestVersion

string $manifestVersion = '1.1'

The current manifest version for this transport.

Details

string
visibility
public
default
1.1
final
false
static
false

$path

string $path = 'null'

The physical location of the transport package.

Details

string
visibility
public
default
null
final
false
static
false

$signature

string $signature = 'null'

A unique signature to identify the package.

Details

string
visibility
public
default
null
final
false
static
false
access
public

$state

integer $state = 'null'

Indicates the state of the xPDOTransport instance.

Details

integer
visibility
public
default
null
final
false
static
false

$vehicles

array $vehicles = 'array'

A map of object vehicles containing payloads of data for transport.

Details

array
visibility
public
default
array
final
false
static
false

$xpdo

\xPDO $xpdo = 'null'

An {@link xPDO} reference controlling this transport instance.

Details

\xPDO
visibility
public
default
null
final
false
static
false
access
public

Methods

__construct

__construct( \xPDO $xpdo, string $signature, string $path ) :

Prepares and returns a new xPDOTransport instance.

Arguments
$xpdo
\xPDO
&$xpdo The xPDO instance accessing this package.
$signature
string
The unique signature of the package.
$path
string
Valid path to the physical transport package.
Details
visibility
public
final
false
static
false

_convertManifestVer1_0

_convertManifestVer1_0( array $manifestVehicles ) : array

Converts older manifest vehicles to 1.0 format.

Arguments
$manifestVehicles
array
A structure representing vehicles from a pre-1.0 manifest format.
Output
array
Vehicle definition structures converted to 1.0 format.
Details
visibility
protected
final
false
static
true
access
private
static

_convertManifestVer1_1

_convertManifestVer1_1( array $vehicles ) : array

Converts 1.0 manifest vehicles to 1.1 format.

Arguments
$vehicles
array
A structure representing vehicles from a pre-1.1 manifest format.
Output
array
Vehicle definition structures converted to 1.1 format.
Details
visibility
protected
final
false
static
true
access
private
static

_pack

_pack( \xPDO $xpdo, string $filename, string $path, string $source ) : boolean

Pack the resources from path relative to source into an archive with filename.

Arguments
$xpdo
\xPDO
&$xpdo A reference to an xPDO instance.
$filename
string
A valid zip archive filename.
$path
string
An absolute file system path location of the resources to pack.
$source
string
A relative portion of path to include in the archive.
Output
boolean
True if packed successfully.
Details
visibility
public
final
false
static
true
todo
Refactor this to be implemented in a service class external to xPDOTransport.
uses
compression.xPDOZip OR compression.PclZip

_unpack

_unpack( \xPDO $xpdo, string $from, string $to ) : array|boolean

Unpack a zip archive to a specified location.

Arguments
$xpdo
\xPDO
&$xpdo A reference to an xPDO instance.
$from
string
An absolute file system location to a valid zip archive.
$to
string
A file system location to extract the contents of the archive to.
Output
array|boolean
An array of unpacked resources or false on failure.
Details
visibility
public
final
false
static
true
todo
Refactor this to be implemented in a service class external to xPDOTransport.
uses
compression.xPDOZip OR compression.PclZip

get

get( string $objFile, array $options = array ) : \xPDOVehicle

Get an {@link xPDOVehicle} instance from an unpacked transport package.

Arguments
$objFile
string
Full path to a payload file to import. The payload file, when included must return a valid {@link xPDOVehicle::$payload}.
$options
array
An array of options to be applied when getting the object.
Output
\xPDOVehicle
The vehicle represented in the file.
Details
visibility
public
final
false
static
false

getAttribute

getAttribute( string $key ) : mixed

Get an attribute of the package manifest.

Arguments
$key
string
The key of the attribute to retrieve.
Output
mixed
The value of the attribute or null if it is not set.
Details
visibility
public
final
false
static
false

install

install( array $options = array ) : boolean

Install vehicles in the package into the sponsor {@link xPDO} instance.

Arguments
$options
array
Install options to be applied to the process.
Output
boolean
true if the vehicles were successfully installed.
Details
visibility
public
final
false
static
false

loadPreserved

loadPreserved( ) : array

Load preserved objects from the previous install().

Output
array
An array of preserved objects, or an empty array.
Details
visibility
public
final
false
static
false

manifestVersion

manifestVersion( array $manifest ) : string

Returns the structure version of the given manifest array.

Arguments
$manifest
array
A valid xPDOTransport manifest array.
Output
string
Version string of the manifest structure.
Details
visibility
public
final
false
static
true
static

pack

pack( ) : boolean

Pack the {@link xPDOTransport} instance in preparation for distribution.

Output
boolean
Indicates if the transport was packed successfully.
Details
visibility
public
final
false
static
false

put

put( mixed $artifact, array $attributes = array ) :

Wrap artifact with an {@link xPDOVehicle} and register in the transport.

Arguments
$artifact
mixed
An artifact to load into the transport.
$attributes
array
A set of attributes related to the artifact; these can be anything from rules describing how to pack or unpack the artifact, or any other data that might be useful when dealing with a transportable artifact.
Details
visibility
public
final
false
static
false

registerVehicle

registerVehicle( \xPDOVehicle $vehicle ) :

Register an xPDOVehicle with this transport instance.

Arguments
$vehicle
\xPDOVehicle
&$vehicle A reference to the vehicle being registered.
Details
visibility
public
final
false
static
false

retrieve

retrieve(  $xpdo,  $source,  $target,  $state = xPDOTransport ) :

Get an existing {@link xPDOTransport} instance.

Arguments
$xpdo
$source
$target
$state
Details
visibility
public
final
false
static
true

setAttribute

setAttribute( string $key, mixed $value ) :

Set an attribute of the package manifest.

Arguments
$key
string
The key identifying the attribute to set.
$value
mixed
The value to set the attribute to.
Details
visibility
public
final
false
static
false

store

store( mixed $location ) :

Store the package to a specified resource location.

Arguments
$location
mixed
The location to store the package.
Details
visibility
public
final
false
static
false
todo
Implement ability to store a package to a specified location, supporting various transport methods.

uninstall

uninstall( array $options = array ) : boolean

Uninstall vehicles in the package from the sponsor {@link xPDO} instance.

Arguments
$options
array
Uninstall options to be applied to the process.
Output
boolean
true if the vehicles were successfully uninstalled.
Details
visibility
public
final
false
static
false

unpack

unpack( \xPDO $xpdo, string $from, string $to, integer $state = xPDOTransport ) : array

Unpack the package to prepare for installation and return a manifest.

Arguments
$xpdo
\xPDO
&$xpdo A reference to an xPDO instance.
$from
string
Filename of the archive containing the transport package.
$to
string
The root path where the contents of the archive should be extracted. This path must be writable by the user executing the PHP process on the server.
$state
integer
The current state of the package, i.e. packed or unpacked.
Output
array
The manifest which is included after successful extraction.
Details
visibility
public
final
false
static
true

writeManifest

writeManifest( ) : boolean

Write the package manifest file.

Output
boolean
Indicates if the manifest was successfully written.
Details
visibility
public
final
false
static
false

writePreserved

writePreserved( ) : boolean

Write objects preserved during install() to file for use by uninstall().

Output
boolean
Indicates if the preserved file was successfully written.
Details
visibility
public
final
false
static
false
Documentation was generated by DocBlox 0.11.2.