\org_openpsa_relatedto_collector

Wrapper for midcom_core_collector. It adds some additional logic to return related objects directly

This class must be used anyplace within MidCOM instead of the real midgard_collector object within the MidCOM Framework. This wrapper is required for the correct operation of many MidCOM services.

It essentially wraps the calls to midcom_helper__dbfactory::new_collector().

Normally you should never have to create an instance of this type directly, instead use the new_collector() method available in the MidCOM DBA API or the midcom_helper__dbfactory::new_collector() method which is still available.

If you have to do create the instance manually however, do not forget to call the \initialize() function after construction, or the creation callbacks will fail.

Summary

Methods
Properties
Constants
__construct()
execute()
list_keys_unchecked()
get_values()
get_rows()
list_keys()
get_subkey()
get()
destroy()
set_key_property()
add_value_property()
count()
count_unchecked()
get_objects()
get_doctrine()
get_current_group()
add_constraint()
add_constraint_with_property()
begin_group()
end_group()
set_limit()
set_offset()
add_order()
get_classname()
add_object_constraint()
add_object_order()
set_object_limit()
get_related_objects_grouped_by()
get_related_objects()
get_related_guids()
$hide_invisible
$denied
No constants found
_convert_class()
_add_visibility_checks()
_reset()
$_visibility_checks_added
$_limit
$_offset
$_orders
$_real_class
$count
$_query
N/A
_list_keys_and_check_privileges()
_set_direction()
_apply_object_constraints()
_apply_object_orders()
_apply_object_limit()
$_user_id
$_object_prefix
$_other_prefix
$_target_classes
$_object_constraints
$_object_limit
$_object_orders
N/A

Properties

$hide_invisible

$hide_invisible : boolean

Set this element to true to hide all items which are currently invisible according to the approval/scheduling settings made using Metadata. This must be set before executing the query.

NOTE: Approval checks not implemented in collector yet

Be aware, that this setting will currently not use the QB to filter the objects accordingly, since there is no way yet to filter against parameters. This will mean some performance impact.

Type

boolean

$denied

$denied : integer

The number of objects for which access was denied.

Type

integer

$_visibility_checks_added

$_visibility_checks_added : boolean

Flag that tracks whether deleted visibility check have already been added

Type

boolean

$_limit

$_limit : integer

The number of records to return to the client at most.

Type

integer

$_offset

$_offset : integer

The offset of the first record the client wants to have available.

Type

integer

$_orders

$_orders : array

The ordering instructions used for this query

Type

array

$_real_class

$_real_class : string

Type that the application expects to retrieve from this instance.

Type

string

$count

$count : integer

The number of records found by the last execute() run. This is -1 as long as no query has been executed. This member is read-only.

Type

integer

$_query

$_query : \midgard\portable\query

The query backend, should be set in constructor. Currently collector or querybuilder

Type

\midgard\portable\query

$_user_id

$_user_id : string

User id for ACL checks. This is set when executing to avoid unnecessary overhead

Type

string

$_object_prefix

$_object_prefix : string

The prefix for query constraints concerning the object(s) at hand

Type

string

$_other_prefix

$_other_prefix : string

The prefix for query constraints concerning the objects we're looking for

Type

string

$_target_classes

$_target_classes : array

The class(es) of the objects we're looking for

Type

array

$_object_constraints

$_object_constraints : array

Additional constraints for the QBs used to find the related objects

Type

array

$_object_limit

$_object_limit : integer

Limit for the QBs used to find the related objects

Type

integer

$_object_orders

$_object_orders : array

Orders for the QBs used to find the related objects

Type

array

Methods

__construct()

__construct(mixed  $guids, mixed  $classes, string  $direction = 'incoming') 

Constructor, takes one or more object guids and classnames and constructs a collector accordingly.

Attention: At least one of these arguments has to be a string

Parameters

mixed $guids

One or more object guids

mixed $classes

One or more target classes

string $direction

incoming or outgoing

execute()

execute() 

list_keys_unchecked()

list_keys_unchecked() 

Runs a query where limit and offset is taken into account <i>prior</i> to execution in the core.

This is useful in cases where you can safely assume read privileges on all objects, and where you would otherwise have to deal with huge resultsets.

Be aware that this might lead to empty resultsets "in the middle" of the actual full resultset when read privileges are missing.

get_values()

get_values(string  $field) 

Convenience function to get all values of a specific column, indexed by GUID

Parameters

string $field

the column name

get_rows()

get_rows(array  $fields, string  $indexed_by = 'guid') : array

Convenience function to get all values of a number of columns They are indexed by GUID unless you specify something else

Parameters

array $fields

The fields to get

string $indexed_by

the column name to be used as index

Returns

array

list_keys()

list_keys() : array

implements midgard_collector::list_keys with ACL checking

Returns

array

get_subkey()

get_subkey(  $key,   $property) 

Parameters

$key
$property

get()

get(  $key) 

Parameters

$key

destroy()

destroy() 

set_key_property()

set_key_property(  $property,   $value = null) 

Parameters

$property
$value

add_value_property()

add_value_property(  $property) 

Parameters

$property

count()

count() 

count_unchecked()

count_unchecked() 

get_objects()

get_objects() 

get_doctrine()

get_doctrine() : \Doctrine\ORM\QueryBuilder

Returns

\Doctrine\ORM\QueryBuilder

get_current_group()

get_current_group() : \Doctrine\ORM\Query\Expr:

Returns

\Doctrine\ORM\Query\Expr:

add_constraint()

add_constraint(string  $field, string  $operator, mixed  $value) : boolean

Add a constraint to the query.

Parameters

string $field

The name of the MgdSchema property to query against.

string $operator

The operator to use for the constraint, currently supported are <, <=, =, <>, >=, >, LIKE. LIKE uses the percent sign ('%') as a wildcard character.

mixed $value

The value to compare against. It should be of the same type as the queried property.

Returns

boolean —

Indicating success.

add_constraint_with_property()

add_constraint_with_property(string  $field, string  $operator, string  $compare_field) : boolean

Add a constraint against another DB column to the query.

Parameters

string $field

The name of the MgdSchema property to query against.

string $operator

The operator to use for the constraint, currently supported are <, <=, =, <>, >=, >, LIKE. LIKE uses the percent sign ('%') as a wildcard character.

string $compare_field

The field to compare against.

Returns

boolean —

Indicating success.

begin_group()

begin_group(string  $operator = 'OR') 

Creates a new logical group within the query. They are set in parentheses in the final SQL and will thus be evaluated with precedence over the normal out-of-group constraints.

While the call lets you decide whether all constraints within the group are AND'ed or OR'ed, only OR constraints make logically sense in this context, which is why this proxy function sets 'OR' as the default operator.

Parameters

string $operator

One of 'OR' or 'AND' denoting the logical operation with which all constraints in the group are concatenated.

end_group()

end_group() 

Ends a group previously started with begin_group().

set_limit()

set_limit(integer  $limit) 

Limits the resultset to contain at most the specified number of records.

Set the limit to zero to retrieve all available records.

Parameters

integer $limit

The maximum number of records in the resultset.

set_offset()

set_offset(integer  $offset) 

Sets the offset of the first record to retrieve. This is a zero based index, so if you want to retrieve from the very first record, the correct offset would be zero, not one.

Parameters

integer $offset

The record number to start with.

add_order()

add_order(string  $field, string  $direction = 'ASC') : boolean

Add an ordering constraint to the query builder.

Parameters

string $field

The name of the MgdSchema property to query against.

string $direction

One of 'ASC' or 'DESC' indicating ascending or descending ordering. The default is 'ASC'.

Returns

boolean —

Indicating success.

get_classname()

get_classname() 

Get the DBA class we're currently working on

add_object_constraint()

add_object_constraint(string  $field, string  $operator, mixed  $value) 

Save object QB constraints for later use

Parameters

string $field

The DB field

string $operator

The constraint operator

mixed $value

The constraint value

add_object_order()

add_object_order(string  $field, string  $direction) 

Save object QB orders for later use

Parameters

string $field

The DB field

string $direction

The direction (ASC, DESC)

set_object_limit()

set_object_limit(integer  $limit) 

Save object QB limit for later use

Parameters

integer $limit

The query limit

get_related_objects_grouped_by()

get_related_objects_grouped_by(string  $key) : array<mixed,\midcom_core_dbaobject>

Parameters

string $key

The column the results should be grouped by

Returns

array<mixed,\midcom_core_dbaobject> —

DBA objects grouped by the specified key

get_related_objects()

get_related_objects(string  $component = false) : array<mixed,\midcom_core_dbaobject>

Parameters

string $component

A component name to further narrow down the results

Returns

array<mixed,\midcom_core_dbaobject> —

DBA objects

get_related_guids()

get_related_guids(string  $component = false) : array

Parameters

string $component

A component name to further narrow down the results

Returns

array —

Array of GUIDs

_convert_class()

_convert_class(string  $classname) : string

Class resolution into the MidCOM DBA system.

Currently, Midgard requires the actual MgdSchema base classes to be used when dealing with the query, so we internally note the corresponding class information to be able to do correct typecasting later.

Parameters

string $classname

The classname which should be converted.

Returns

string —

MgdSchema class name

_add_visibility_checks()

_add_visibility_checks() 

_reset()

_reset() 

Resets some internal variables for re-execute

_list_keys_and_check_privileges()

_list_keys_and_check_privileges(  $apply_offset_limit = true) 

Parameters

$apply_offset_limit

_set_direction()

_set_direction(  $dir) 

Parameters

$dir

_apply_object_constraints()

_apply_object_constraints(\midcom_core_querybuilder  $qb) 

Apply constraints (if any) to the final object QBs

Parameters

\midcom_core_querybuilder $qb

the QB instance in question

_apply_object_orders()

_apply_object_orders(\midcom_core_querybuilder  $qb) 

Apply orders (if any) to the final object QBs

Parameters

\midcom_core_querybuilder $qb

the QB instance in question

_apply_object_limit()

_apply_object_limit(\midcom_core_querybuilder  $qb) 

Apply the limit (if any) to the final object QBs

Parameters

\midcom_core_querybuilder $qb

the QB instance in question