PHP 클래스 RedBeanPHP\DuplicationManager

저자: Gabor de Mooij and the RedBeanPHP Community
파일 보기 프로젝트 열기: gabordemooij/redbean 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$associationManager AssociationManager
$cacheTables array
$columns array
$filters array
$redbean RedBeanPHP\OODB
$tables array
$toolbox ToolBox

공개 메소드들

메소드 설명
__construct ( ToolBox $toolbox ) Constructor, creates a new instance of DupManager.
camelfy ( array $array, boolean $dolphinMode = false ) : array Recursively turns the keys of an array into camelCase.
dup ( RedBeanPHP\OODBBean $bean, array $trail = [], boolean $preserveIDs = FALSE ) : RedBeanPHP\OODBBean Makes a copy of a bean. This method makes a deep copy of the bean.The copy will have the following features.
exportAll ( array | RedBeanPHP\OODBBean $beans, boolean $parents = FALSE, array $filters = [], string $caseStyle = 'snake' ) : array Exports a collection of beans recursively.
getSchema ( ) : array Returns a schema array for cache.
setCacheTables ( boolean $yesNo ) Indicates whether you want the duplication manager to cache the database schema.
setFilters ( array $filters ) : void A filter array is an array with table names.
setTables ( array $tables ) : void For better performance you can pass the tables in an array to this method.

보호된 메소드들

메소드 설명
duplicate ( RedBeanPHP\OODBBean $bean, array $trail = [], boolean $preserveIDs = FALSE ) : RedBeanPHP\OODBBean
hasOwnList ( string $type, string $target ) : boolean Determines whether the bean has an own list based on schema inspection from realtime schema or cache.
hasSharedList ( string $type, string $target ) : boolean Determines whether the bea has a shared list based on schema inspection from realtime schema or cache.

비공개 메소드들

메소드 설명
copyOwnBeans ( RedBeanPHP\OODBBean $copy, string $owned, array $beans, array $trail, boolean $preserveIDs ) : void Copies the own beans in a bean, i.e. all the ownBean-lists.
copySharedBeans ( RedBeanPHP\OODBBean $copy, string $shared, array $beans ) : void Copies the shared beans in a bean, i.e. all the sharedBean-lists.
createCopy ( RedBeanPHP\OODBBean $bean ) : RedBeanPHP\OODBBean Creates a copy of bean $bean and copies all primitive properties (not lists) and the parents beans to the newly created bean. Also sets the ID of the bean to 0.
getListNames ( string $typeName ) : array Given the type name of a bean this method returns the canonical names of the own-list and the shared-list properties respectively.
inTrailOrAdd ( array &$trail, RedBeanPHP\OODBBean $bean ) : boolean Generates a key from the bean type and its ID and determines if the bean occurs in the trail, if not the bean will be added to the trail.

메소드 상세

__construct() 공개 메소드

Constructor, creates a new instance of DupManager.
public __construct ( ToolBox $toolbox )
$toolbox ToolBox

camelfy() 공개 메소드

Recursively turns the keys of an array into camelCase.
public camelfy ( array $array, boolean $dolphinMode = false ) : array
$array array array to camelize
$dolphinMode boolean whether you want the exception for IDs.
리턴 array

dup() 공개 메소드

- All beans in own-lists will be duplicated as well - All references to shared beans will be copied but not the shared beans themselves - All references to parent objects (_id fields) will be copied but not the parents themselves In most cases this is the desired scenario for copying beans. This function uses a trail-array to prevent infinite recursion, if a recursive bean is found (i.e. one that already has been processed) the ID of the bean will be returned. This should not happen though. Note: This function does a reflectional database query so it may be slow. Note: this function actually passes the arguments to a protected function called duplicate() that does all the work. This method takes care of creating a clone of the bean to avoid the bean getting tainted (triggering saving when storing it).
public dup ( RedBeanPHP\OODBBean $bean, array $trail = [], boolean $preserveIDs = FALSE ) : RedBeanPHP\OODBBean
$bean RedBeanPHP\OODBBean bean to be copied
$trail array for internal usage, pass array()
$preserveIDs boolean for internal usage
리턴 RedBeanPHP\OODBBean

duplicate() 보호된 메소드

또한 보기: DuplicationManager::dup
protected duplicate ( RedBeanPHP\OODBBean $bean, array $trail = [], boolean $preserveIDs = FALSE ) : RedBeanPHP\OODBBean
$bean RedBeanPHP\OODBBean bean to be copied
$trail array trail to prevent infinite loops
$preserveIDs boolean preserve IDs
리턴 RedBeanPHP\OODBBean

exportAll() 공개 메소드

This method will export an array of beans in the first argument to a set of arrays. This can be used to send JSON or XML representations of bean hierarchies to the client. For every bean in the array this method will export: - contents of the bean - all own bean lists (recursively) - all shared beans (but not THEIR own lists) If the second parameter is set to TRUE the parents of the beans in the array will be exported as well (but not THEIR parents). The third parameter can be used to provide a white-list array for filtering. This is an array of strings representing type names, only the type names in the filter list will be exported. The fourth parameter can be used to change the keys of the resulting export arrays. The default mode is 'snake case' but this leaves the keys as-is, because 'snake' is the default case style used by RedBeanPHP in the database. You can set this to 'camel' for camel cased keys or 'dolphin' (same as camelcase but id will be converted to ID instead of Id).
public exportAll ( array | RedBeanPHP\OODBBean $beans, boolean $parents = FALSE, array $filters = [], string $caseStyle = 'snake' ) : array
$beans array | RedBeanPHP\OODBBean beans to be exported
$parents boolean also export parents
$filters array only these types (whitelist)
$caseStyle string case style identifier
리턴 array

getSchema() 공개 메소드

You can use the return value of this method as a cache, store it in RAM or on disk and pass it to setTables later.
public getSchema ( ) : array
리턴 array

hasOwnList() 보호된 메소드

Determines whether the bean has an own list based on schema inspection from realtime schema or cache.
protected hasOwnList ( string $type, string $target ) : boolean
$type string bean type to get list for
$target string type of list you want to detect
리턴 boolean

hasSharedList() 보호된 메소드

Determines whether the bea has a shared list based on schema inspection from realtime schema or cache.
protected hasSharedList ( string $type, string $target ) : boolean
$type string bean type to get list for
$target string type of list you are looking for
리턴 boolean

setCacheTables() 공개 메소드

If this flag is set to TRUE the duplication manager will query the database schema only once. Otherwise the duplicationmanager will, by default, query the schema every time a duplication action is performed (dup()).
public setCacheTables ( boolean $yesNo )
$yesNo boolean TRUE to use caching, FALSE otherwise

setFilters() 공개 메소드

By setting a table filter you can make the duplication manager only take into account certain bean types. Other bean types will be ignored when exporting or making a deep copy. If no filters are set all types will be taking into account, this is the default behavior.
public setFilters ( array $filters ) : void
$filters array list of tables to be filtered
리턴 void

setTables() 공개 메소드

If the tables are available the duplication manager will not query them so this might be beneficial for performance. This method allows two array formats: array( TABLE1, TABLE2 ... ) or array( TABLE1 => array( COLUMN1, COLUMN2 ... ) ... )
public setTables ( array $tables ) : void
$tables array a table cache array
리턴 void

프로퍼티 상세

$associationManager 보호되어 있는 프로퍼티

protected AssociationManager,RedBeanPHP $associationManager
리턴 AssociationManager

$cacheTables 보호되어 있는 프로퍼티

protected array $cacheTables
리턴 array

$columns 보호되어 있는 프로퍼티

protected array $columns
리턴 array

$filters 보호되어 있는 프로퍼티

protected array $filters
리턴 array

$redbean 보호되어 있는 프로퍼티

protected OODB,RedBeanPHP $redbean
리턴 RedBeanPHP\OODB

$tables 보호되어 있는 프로퍼티

protected array $tables
리턴 array

$toolbox 보호되어 있는 프로퍼티

protected ToolBox,RedBeanPHP $toolbox
리턴 ToolBox