SnapBulkAction Class Reference
[Utility Classes]

Collection of static methods to perform queries or actions on large numbers of Snap objects. More...

Inheritance diagram for SnapBulkAction:

Inheritance graph
[legend]

List of all members.

Static Public Member Functions

static bulkApprove ($base, $from, $to, $options=array())
 Changes state of selected versions to new state.
static listDirectoriesRecursive ($base= '//', $depth=self::DEPTH_ALL, $constraint=array(), $limit=array(), $order=array())
 Retrieves a list of directories contained within a directory and possibly its children.
static listResourcesRecursive ($base= '//', $depth=self::DEPTH_ALL, $constraint=array(), $limit=array(), $order=array())
 Retrieves a list of resources contained within a directory and possibly its children.
static listVersionsRecursive ($base= '//', $depth=self::DEPTH_ALL, $constraint=array(), $limit=array(), $order=array())
 Retrieves a list of versions contained within a directory and possibly its children.

Public Attributes

const DEPTH_ALL
const DEPTH_IMMEDIATE


Detailed Description

Collection of static methods to perform queries or actions on large numbers of Snap objects.

This class is a repository of static methods that can perform queries and actions on groups of Snap objects that may not be easily retrievable using methods available from, e.g., SnapDirectory. For example, this class has a method that lets you change the status of a set of versions from one state to another. The set of versions can be derived by recursively collecting versions from a directory tree.


Member Function Documentation

static SnapBulkAction::bulkApprove ( base,
from,
to,
options = array() 
) [static]

Changes state of selected versions to new state.

You can use this method to, e.g., approve all pending versions to dev. You can use any of the following transitions:

  • In Progress to Pending
  • In Progress to Defunct
  • Pending to Dev
  • Pending to Live
  • Pending to In Progress
  • Pending to Defunct
  • Dev to Live
  • Dev to Defunct
  • Live to Defunct
  • Defunct to Destroyed
Any other transitions will result in an error. For some transitions, you may want to only apply the transition to the first matching version in a resource. For example, it would probably only make sense to approve for dev the first pending version found, instead of all pending versions. That can be specified in the $options parameter, along with some options that specify what kind of information to return, whether to do a recursive search for versions, or whether to just do a "dry run" (do everything but actually apply the action on the versions -- useful for seeing what would happen if the operation were to run).

Parameters:
$base [string]: base directory to search for versions in
$from [int]: one of the SnapVersion STATUS_* constants, specifying the status that versions will be converted from; versions not having this status will not be converted
$to [int]: one of the SnapVersion STATUS_* constants, specifying the status that matching versions will be converted to; must follow a valid transition as given above
$options [array]: there are four options that can be specified:
  • recursive -- if true, descendant directories of $base will be searched for versions
  • single -- if true, only apply a change to the first version in a given resource that matches $from
  • fullStats -- if true, return fuller statistics about what was done, what failed, etc.
  • dryRun -- if true, no versions will actually be modified; return statistics will show what would have been done
Returns:
[array]: two elements giving the number of successful and failed version modifications; if the single option is used, then a third element will give the number of versions that were skipped; if fullStats is used, a fourth element (third if single not set) will be an array with a string for each version converted describing whether it succeeded or failed and how (that array is keyed by version path).

static SnapBulkAction::listDirectoriesRecursive ( base = '//',
depth = self::DEPTH_ALL,
constraint = array(),
limit = array(),
order = array() 
) [static]

Retrieves a list of directories contained within a directory and possibly its children.

This function searches a directory, and optionally its descendant directories, for directories. You can specify additional constraints on what directories to search for. By default, the function will return all directories in the entire Snap2 tree (excluding those in /DELETED/). Note that the base directory is included in the search results.

Parameters:
$base [string]: base directory to start from (defaults to '//')
$depth [int]: either DEPTH_IMMEDIATE (non-recursive) or DEPTH_ALL (recursive)
$constraint [array]: array of constraints
$limit [mixed]: describes how many results to return
$order [array]: describes how to order the results
Returns:
[array]: associative array of directory ID => path entries (no directory objects are created), or null if there was an error

static SnapBulkAction::listResourcesRecursive ( base = '//',
depth = self::DEPTH_ALL,
constraint = array(),
limit = array(),
order = array() 
) [static]

Retrieves a list of resources contained within a directory and possibly its children.

This function searches a directory, and optionally its descendant directories, for resources. You can specify additional constraints on what resources to search for. By default, the function will return all resources in the entire Snap2 tree (excluding those in /DELETED/).

Parameters:
$base [string]: base directory to start from (defaults to '//')
$depth [int]: either DEPTH_IMMEDIATE (non-recursive) or DEPTH_ALL (recursive)
$constraint [array]: array of constraints
$limit [mixed]: describes how many results to return
$order [array]: describes how to order the results
Returns:
[array]: associative array of resource ID => path entries (no resource objects are created), or null if there was an error

static SnapBulkAction::listVersionsRecursive ( base = '//',
depth = self::DEPTH_ALL,
constraint = array(),
limit = array(),
order = array() 
) [static]

Retrieves a list of versions contained within a directory and possibly its children.

This function searches a directory, and optionally its descendant directories, for versions. You can specify additional constraints on what versions to search for. By default, the function will return all versions in the entire Snap2 tree (excluding those in /DELETED/).

Parameters:
$base [string]: base directory to start from (defaults to '//')
$depth [int]: either DEPTH_IMMEDIATE (non-recursive) or DEPTH_ALL (recursive)
$constraint [array]: array of constraints
$limit [mixed]: describes how many results to return
$order [array]: describes how to order the results
Returns:
[array]: associative array of version ID => path entries (no version objects are created), or null if there was an error


Member Data Documentation

Search current directory and subdirectories recursively

Only search the current directory/resource and none its subdirectories


The documentation for this class was generated from the following file:

Generated on Wed Nov 24 02:03:07 2010 for Common by  doxygen 1.5.6