\midcom_helper_reflector_copy

The Grand Unified Reflector, copying helper class

Note, that the request data, for ease of use, already contains the L10n Databases of the Component and MidCOM itself located in this class. They are stored as 'l10n' and 'l10n_midcom'. Also available as 'config' is the current component configuration.

Summary

Methods
Properties
Constants
__construct()
__get()
__isset()
set_active_leaf()
add_stylesheet()
get_workflow()
get_object()
get_parent_property()
get_target_properties()
resolve_object()
copy_tree()
copy_object()
copy_parameters()
copy_metadata()
copy_attachments()
copy_privileges()
copy_object_tree()
execute()
$_component
$source
$target
$exclude
$root_object_values
$copy_attachments
$copy_parameters
$copy_privileges
$copy_metadata
$copy_tree
$copy_metadata_fields
$halt_on_errors
$errors
$new_objects
$new_root_object
$_i18n
$_l10n
$_l10n_midcom
$_config
No constants found
No protected methods found
No protected properties found
N/A
_copy_data()
$_services
N/A

Properties

$_component

$_component : string

The name of the component, e.g. net.nehmer.static. Should be used whenever the component's name is required instead of hardcoding it.

Type

string

$source

$source : mixed

Source

Type

mixed — GUID, MgdSchema or MidCOM dba object

$target

$target : mixed

Target

Type

mixed — GUID, MgdSchema or MidCOM dba object

$exclude

$exclude : array

Exclusion list

Type

array — List of GUIDs of objects that shall not be copied

$root_object_values

$root_object_values : array

Override properties of the new root object. This feature is directed for overriding e.g. parent information.

Type

array — Property-value pairs

$copy_attachments

$copy_attachments : boolean

Switch for attachments

Type

boolean

$copy_parameters

$copy_parameters : boolean

Switch for parameters

Type

boolean

$copy_privileges

$copy_privileges : boolean

Switch for privileges

Type

boolean

$copy_metadata

$copy_metadata : boolean

Switch for metadata

Type

boolean

$copy_tree

$copy_tree : boolean

Copy the whole tree

Type

boolean

$copy_metadata_fields

$copy_metadata_fields : 

Metadata fields that shall be copied

Type

$halt_on_errors

$halt_on_errors : boolean

Switch for halt on error. If this is set to false, errors will be reported, but will not stop executing

Type

boolean — Set to false to continue on errors

$errors

$errors : array

Encountered errors

Type

array

$new_objects

$new_objects : array

Newly created objects

Type

array

$new_root_object

$new_root_object : 

New root object

Type

$_i18n

$_i18n : \midcom_services_i18n

A handle to the i18n service.

Type

\midcom_services_i18n

$_l10n

$_l10n : \midcom_services_i18n_l10n

The components' L10n string database.

Type

\midcom_services_i18n_l10n

$_l10n_midcom

$_l10n_midcom : \midcom_services_i18n_l10n

The global MidCOM string database.

Type

\midcom_services_i18n_l10n

$_config

$_config : \midcom_helper_configuration

The current configuration.

Type

\midcom_helper_configuration

$_services

$_services : array

Array that holds the already instantiated services

Type

array

Methods

__construct()

__construct() 

Initialize all member variables, remember to set $_component before calling this constructor from your derived classes.

__get()

__get(  $field) 

Parameters

$field

__isset()

__isset(  $field) 

Parameters

$field

set_active_leaf()

set_active_leaf(  $leaf_id) 

Parameters

$leaf_id

add_stylesheet()

add_stylesheet(string  $url, string  $media = false) 

Convenience shortcut for adding CSS files

Parameters

string $url

The stylesheet URL

string $media

The media type(s) for the stylesheet, if any

get_workflow()

get_workflow(string  $identifier, array  $options = array()) : \midcom\workflow\dialog

Parameters

string $identifier
array $options

Returns

\midcom\workflow\dialog

get_object()

get_object() : mixed

Get the newly created root object

Returns

mixed —

Lowest level new MgdSchema object

get_parent_property()

get_parent_property(mixed  $object) : string

Get the parent property for overriding it

Parameters

mixed $object

MgdSchema object for resolving the parent property

Returns

string —

Parent property

get_target_properties()

get_target_properties(mixed  $object) : array

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

Parameters

mixed $object

MgdSchema object or MidCOM db object

Returns

array —

id, parent property, class and label of the object

resolve_object()

resolve_object(  $object) : mixed

Resolve MgdSchema object from guid or miscellaneous extended object

Parameters

$object

Returns

mixed —

MgdSchema object or false on failure

copy_tree()

copy_tree(mixed  $source, mixed  $parent) : mixed

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

mixed $source

GUID or MgdSchema object that will be copied

mixed $parent

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

Returns

mixed —

False on failure, newly created MgdSchema root object on success

copy_object()

copy_object(  $source,   $parent = null, array  $defaults = array()) : boolean

Copy an object

Parameters

$source
$parent
array $defaults

Returns

boolean —

Indicating success

copy_parameters()

copy_parameters(mixed  $source, mixed  $target) : boolean

Copy parameters for the object

Parameters

mixed $source

MgdSchema object for reading the parameters

mixed $target

MgdSchema object for storing the parameters

Returns

boolean —

Indicating success

copy_metadata()

copy_metadata(mixed  $source, mixed  $target) : boolean

Copy metadata for the object

Parameters

mixed $source

MgdSchema object for reading the metadata

mixed $target

MgdSchema object for storing the metadata

Returns

boolean —

Indicating success

copy_attachments()

copy_attachments(  $source,   $target) : boolean

Copy attachments

Parameters

$source
$target

Returns

boolean —

Indicating success

copy_privileges()

copy_privileges(mixed  $source, mixed  $target) : boolean

Copy privileges

Parameters

mixed $source

MgdSchema object for reading the privileges

mixed $target

MgdSchema object for storing the privileges

Returns

boolean —

Indicating success

copy_object_tree()

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

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

mixed $source

GUID or MgdSchema object that will be copied

mixed $parent

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

array $exclude

IDs that will be excluded from the copying

boolean $copy_parameters

Switch to determine if the parameters should be copied

boolean $copy_metadata

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

boolean $copy_attachments

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

Returns

mixed —

False on failure, newly created MgdSchema root object on success

execute()

execute() : boolean

Dispatches the copy command according to the attributes set

Returns

boolean —

Indicating success

_copy_data()

_copy_data(string  $type,   $source,   $target) : boolean

Copy object data

Parameters

string $type

The type of data to copy

$source
$target

Returns

boolean —

Indicating success