Namespace: RedBeanPHP
Copyright:
copyright (c) G.J.G.T. (Gabor) de Mooij and the RedBeanPHP Community
This source file is subject to the BSD/GPLv2 License that is bundled
with this source code in the file license.txt.
License:
BSD/GPLv2
Author:
Gabor de Mooij and the RedBeanPHP Community
File:
RedBeanPHP/DuplicationManager.php
Located at DuplicationManager.php
Methods summary
protected
boolean
|
#
hasOwnList( string $type, string $target )
Determines whether the bean has an own list based on
schema inspection from realtime schema or cache.
Determines whether the bean has an own list based on
schema inspection from realtime schema or cache.
Parameters
- $type
- bean type to get list for
- $target
- type of list you want to detect
Returns
boolean
|
protected
boolean
|
#
hasSharedList( string $type, string $target )
Determines whether the bea has a shared list based on
schema inspection from realtime schema or cache.
Determines whether the bea has a shared list based on
schema inspection from realtime schema or cache.
Parameters
- $type
- bean type to get list for
- $target
- type of list you are looking for
Returns
boolean
|
protected
RedBeanPHP\OODBBean
|
#
duplicate( RedBeanPHP\OODBBean $bean, array $trail = array(), boolean $preserveIDs = FALSE )
Parameters
- $bean
- bean to be copied
- $trail
- trail to prevent infinite loops
- $preserveIDs
- preserve IDs
Returns
See
|
public
|
#
__construct( RedBeanPHP\ToolBox $toolbox )
Constructor,
creates a new instance of DupManager.
Constructor,
creates a new instance of DupManager.
Parameters
|
public
array
|
#
camelfy( array $array, boolean $dolphinMode = false )
Recursively turns the keys of an array into
camelCase.
Recursively turns the keys of an array into
camelCase.
Parameters
- $array
- array to camelize
- $dolphinMode
- whether you want the exception for IDs.
Returns
array
|
public
|
#
setTables( array $tables )
For better performance you can pass the tables in an array to this method.
If the tables are available the duplication manager will not query them so
this might be beneficial for performance.
For better performance you can pass the tables in an array to this method.
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 ... ) ... )
Parameters
- $tables
- a table cache array
|
public
array
|
#
getSchema( )
Returns a schema array for cache.
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.
Returns a schema array for cache.
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.
Returns
array
|
public
|
#
setCacheTables( boolean $yesNo )
Indicates whether you want the duplication manager to cache the database schema.
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()).
Indicates whether you want the duplication manager to cache the database schema.
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()).
Parameters
- $yesNo
- TRUE to use caching, FALSE otherwise
|
public
|
#
setFilters( array $filters )
A filter array is an array with table names.
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.
A filter array is an array with table names.
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.
Parameters
- $filters
- list of tables to be filtered
|
public
RedBeanPHP\OODBBean
|
#
dup( RedBeanPHP\OODBBean $bean, array $trail = array(), boolean $preserveIDs = FALSE )
Makes a copy of a bean. This method makes a deep copy
of the bean.The copy will have the following features.
- 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.
Makes a copy of a bean. This method makes a deep copy
of the bean.The copy will have the following features.
- 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).
Parameters
- $bean
- bean to be copied
- $trail
- for internal usage, pass array()
- $preserveIDs
- for internal usage
Returns
|
public
array
|
#
exportAll( array|RedBeanPHP\OODBBean $beans, boolean $parents = FALSE, array $filters = array(), string $caseStyle = 'snake' )
Exports a collection of beans recursively.
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.
Exports a collection of beans recursively.
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).
Parameters
- $beans
- beans to be exported
- $parents
- also export parents
- $filters
- only these types (whitelist)
- $caseStyle
- case style identifier
Returns
array
|