The Grand Unified Reflector, copying helper class

package midcom.helper.reflector

 Methods

copy_attachments (mixed $source, mixed $target)

Copy attachments

Parameters

$source

mixed&$source MgdSchema object for reading the attachments

$target

mixed&$target MgdSchema object for storing the attachments

Returns

booleanIndicating success

copy_object (mixed $source, mixed $parent, array $defaults)

Copy an object

Parameters

$source

mixed&$source MgdSchema object for reading the parameters

$parent

mixed&$parent MgdSchema parent object

$defaults

array

Returns

booleanIndicating success

copy_object_tree (mixed $source, mixed $parent, array $exclude, boolean $copy_parameters, boolean $copy_metadata, boolean $copy_attachments)

Copy an object tree.
Static

Both source and parent may be liberally filled. Source can be either MgdSchema or MidCOM db object or GUID of the object and parent can be

  • MgdSchema object
  • MidCOM db object
  • predefined target array (@see get_target_properties())
  • ID or GUID of the object
  • left empty to copy as a parentless object

This method is self-aware and will refuse to perform any infinite loops (e.g. to copy itself to its descendant, copying itself again and again and again).

Eventually this method will return the first root object that was created, i.e. the root of the new tree.

Parameters

$source

mixedGUID or MgdSchema object that will be copied

$parent

mixedMgdSchema or MidCOM db object, predefined array or ID of the parent object

$exclude

arrayIDs that will be excluded from the copying

$copy_parameters

booleanSwitch to determine if the parameters should be copied

$copy_metadata

booleanSwitch to determine if the metadata should be copied (excluding created and published)

$copy_attachments

booleanSwitch to determine if the attachments should be copied (creates only a new link, doesn't duplicate the content)

Returns

mixedFalse on failure, newly created MgdSchema root object on success

copy_parameters (mixed $source, mixed $target)

Copy parameters for the object

Parameters

$source

mixed&$source MgdSchema object for reading the parameters

$target

mixed&$target MgdSchema object for storing the parameters

Returns

booleanIndicating success

copy_privileges (mixed $source, mixed $target)

Copy privileges

Parameters

$source

mixed&$source MgdSchema object for reading the privileges

$target

mixed&$target MgdSchema object for storing the privileges

Returns

booleanIndicating success

copy_tree (mixed $source, mixed $parent)

Copy an object tree.

Both source and parent may be liberally filled. Source can be either MgdSchema or MidCOM db object or GUID of the object and parent can be

  • MgdSchema object
  • MidCOM db object
  • predefined target array (@see get_target_properties())
  • ID or GUID of the object
  • left empty to copy as a parentless object

This method is self-aware and will refuse to perform any infinite loops (e.g. to copy itself to its descendant, copying itself again and again and again).

Eventually this method will return the first root object that was created, i.e. the root of the new tree.

Parameters

$source

mixedGUID or MgdSchema object that will be copied

$parent

mixedMgdSchema or MidCOM db object, predefined array or ID of the parent object

Returns

mixedFalse on failure, newly created MgdSchema root object on success

execute ()

Dispatches the copy command according to the attributes set

Returns

booleanIndicating success

get_object ()

Get the newly created root object

Returns

mixedLowest level new MgdSchema object

get_object_properties (mixed $object)

Get object properties

Parameters

$object

mixed&$object

Returns

array

get_parent_property (mixed $object)

Get the parent property for overriding it

Parameters

$object

mixed&$object MgdSchema object for resolving the parent property

Returns

stringParent property

get_target_properties (mixed $object)

Get the target properties and return an array that is used e.g.
Static

in copying

Parameters

$object

mixedMgdSchema object or MidCOM db object

Returns

arrayid, parent property, class and label of the object

resolve_object (mixed $object, string $class)

Resolve MgdSchema object from guid or miscellaneous extended object
Static

Parameters

$object

mixed&$object MgdSchema object, GUID or ID

$class

stringMgdSchema class for resolving ID

Returns

mixedMgdSchema object or false on failure

_copy_data (string $type, mixed $source, mixed $target)

Copy object data

Parameters

$type

stringThe type of data to copy

$source

mixed&$source MgdSchema object for reading the parameters

$target

mixed&$target MgdSchema object for storing the parameters

Returns

booleanIndicating success

 Properties

 

boolean $allow_name_catenate

Switch for name catenating
 

boolean $copy_attachments

Switch for attachments
     

boolean $copy_parameters

Switch for parameters
 

boolean $copy_privileges

Switch for privileges
 

boolean $copy_tree

Copy the whole tree
 

array $errors

Encountered errors
 

array $exclude

Exclusion list
 

boolean $halt_on_errors

Switch for halt on error.

If this is set to false, errors will be reported, but will not stop executing

 

array $new_objects

Newly created objects
 

mixed $new_root_object

New root object
 

array $root_object_values

Override properties of the new root object.

This feature is directed for overriding e.g. parent information.

 

mixed $source

Source
 

mixed $target

Target
 

array $properties

Properties for each encountered MgdSchema object