PHP Class Shanty_Mongo

Author: Coen Hyde
ファイルを表示 Open project: coen-hyde/shanty-mongo Class Usage Examples

Protected Properties

Property Type Description
$_connectionGroups
$_initialised
$_requirementCreators
$_requirements
$_validOperations

Public Methods

Method Description
addConnections ( array $options ) Add connections Shanty Mongo
addMaster ( Shanty_Mongo_Connection $connection, integer $weight = 1, $connectionGroup = 'default' ) Add a connection to a master server
addSlave ( Shanty_Mongo_Connection $connection, $weight = 1, $connectionGroup = 'default' ) Add a connection to a slaver server
createRequirement ( $name, $options = null ) : mixed Create a requirement
getConnectionGroup ( string $name ) : Shanty_Mongo_Connection_Group Get a connection group. If it doesn't already exist, create it
getConnectionGroups ( ) : array Get a list of all connection groups
getReadConnection ( string $connectionGroupName = 'default' ) : Shanty_Mongo_Connection Get a read connection
getWriteConnection ( string $connectionGroupName = 'default' ) : Shanty_Mongo_Connection Get a write connection
hasConnectionGroup ( string $name ) Determine if a connection group exists
init ( ) Initialise Shanty_Mongo. In particular all the requirements.
isValidOperation ( string $operation ) Deterimine if an operation is valid
makeClean ( ) Return Shanty_Mongo to pre-init status
removeConnectionGroups ( ) Remove all connection groups
removeRequirementCreators ( ) Remove all requirement creators
removeRequirements ( ) Remove all requirements
retrieveRequirement ( $name, $options = null ) : mixed Get the requirement matching the name provided
setConnectionGroup ( string $name, Shanty_Mongo_Connection_Group $connectionGroup ) Set a connection group
storeRequirement ( $name, $requirement ) Add requirements to use in validation of document properties
storeRequirementCreator ( $regex, Closure $function ) Add a creator of requirements

Method Details

addConnections() public static method

Add connections Shanty Mongo
public static addConnections ( array $options )
$options array

addMaster() public static method

Add a connection to a master server
public static addMaster ( Shanty_Mongo_Connection $connection, integer $weight = 1, $connectionGroup = 'default' )
$connection Shanty_Mongo_Connection
$weight integer

addSlave() public static method

Add a connection to a slaver server
public static addSlave ( Shanty_Mongo_Connection $connection, $weight = 1, $connectionGroup = 'default' )
$connection Shanty_Mongo_Connection
$weight

createRequirement() public static method

Create a requirement
public static createRequirement ( $name, $options = null ) : mixed
$name String Name of requirement
return mixed

getConnectionGroup() public static method

Get a connection group. If it doesn't already exist, create it
public static getConnectionGroup ( string $name ) : Shanty_Mongo_Connection_Group
$name string The name of the connection group
return Shanty_Mongo_Connection_Group

getConnectionGroups() public static method

Get a list of all connection groups
public static getConnectionGroups ( ) : array
return array

getReadConnection() public static method

Get a read connection
public static getReadConnection ( string $connectionGroupName = 'default' ) : Shanty_Mongo_Connection
$connectionGroupName string The connection group name
return Shanty_Mongo_Connection

getWriteConnection() public static method

Get a write connection
public static getWriteConnection ( string $connectionGroupName = 'default' ) : Shanty_Mongo_Connection
$connectionGroupName string The connection group name
return Shanty_Mongo_Connection

hasConnectionGroup() public static method

Determine if a connection group exists
public static hasConnectionGroup ( string $name )
$name string The name of the connection group

init() public static method

Initialise Shanty_Mongo. In particular all the requirements.
public static init ( )

isValidOperation() public static method

Deterimine if an operation is valid
public static isValidOperation ( string $operation )
$operation string

makeClean() public static method

Return Shanty_Mongo to pre-init status
public static makeClean ( )

removeConnectionGroups() public static method

Remove all connection groups
public static removeConnectionGroups ( )

removeRequirementCreators() public static method

Remove all requirement creators
public static removeRequirementCreators ( )

removeRequirements() public static method

Remove all requirements
public static removeRequirements ( )

retrieveRequirement() public static method

Get the requirement matching the name provided
public static retrieveRequirement ( $name, $options = null ) : mixed
$name String Name of requirement
return mixed

setConnectionGroup() public static method

Set a connection group
public static setConnectionGroup ( string $name, Shanty_Mongo_Connection_Group $connectionGroup )
$name string
$connectionGroup Shanty_Mongo_Connection_Group

storeRequirement() public static method

Add requirements to use in validation of document properties
public static storeRequirement ( $name, $requirement )
$name String Name of requirement
$requirement mixed

storeRequirementCreator() public static method

Add a creator of requirements
public static storeRequirementCreator ( $regex, Closure $function )
$function Closure

Property Details

$_connectionGroups protected_oe static_oe property

protected static $_connectionGroups

$_initialised protected_oe static_oe property

protected static $_initialised

$_requirementCreators protected_oe static_oe property

protected static $_requirementCreators

$_requirements protected_oe static_oe property

protected static $_requirements

$_validOperations protected_oe static_oe property

protected static $_validOperations