Helper class for object name handling

package midcom.helper.reflector

 Methods

__construct ($object)

Parameters

$object

generate_unique_name (string $title_property, string $extension)

Generates an unique name for the given object.

1st IF name is empty, we generate one from title (if title is empty too, we return false) Then we check if it's unique, if not we add an incrementing number to it (before this we make some educated guesses about a good starting value)

Parameters

$title_property

stringProperty of the object to use at title, if null will be reflected (see midcom_helper_reflector::get_object_title())

$extension

stringThe file extension, when working with attachments

Returns

stringstring usable as name or boolean false on critical failures

get_object_name (string $name_property)

Resolves the "name" of given object

Parameters

$name_property

stringproperty to use as "name", if left to default (null), will be reflected

Returns

stringvalue of name property or boolean false on failure

name_is_clean ($name_property)

Checks for "clean" URL name
see \http://trac.midgard-project.org/ticket/809

Parameters

$name_property

property to use as "name", if left to default (null), will be reflected

Returns

booleanindicating cleanliness

name_is_clean_or_empty ($name_property)

Checks for "clean" URL name, this variant accepts empty name
see \http://trac.midgard-project.org/ticket/809

Parameters

$name_property

property to use as "name", if left to default (null), will be reflected

Returns

booleanindicating cleanliness

name_is_safe ($name_property)

Checks for URL-safe name
see \http://trac.midgard-project.org/ticket/809

Parameters

$name_property

property to use as "name", if left to default (null), will be reflected

Returns

booleanindicating safety

name_is_safe_or_empty (string $name_property)

Checks for URL-safe name, this variant accepts empty name
see \http://trac.midgard-project.org/ticket/809

Parameters

$name_property

stringproperty to use as "name", if left to default (null), will be reflected

Returns

booleanindicating safety

name_is_unique ()

Method to check that none of given objects siblings have same name.

Returns

booleanindicating uniqueness

name_is_unique_or_empty ()

Check that none of given objects siblings have same name, or the name is empty.

Returns

booleanindicating uniqueness

_generate_unique_name_resolve_i (string $current_name, string $extension)

Helper to resolve the base value for the incrementing suffix and for the name.
see \midcom_helper_reflector_nameresolver::generate_unique_name()

Parameters

$current_name

stringthe "current name" of the object (might not be the actual name value see the title logic in generate_unique_name())

$extension

stringThe file extension, when working with attachments

Returns

arrayfirst key is the resolved $i second is the $base_name, which is $current_name without numeric suffix

_get_root_qb ($schema_type)

Parameters

$schema_type

_get_sibling_qb ($schema_type, $parent)

Parameters

$schema_type

$parent

_name_is_unique_check_roots (array $sibling_classes)

Helper for name_is_unique, checks uniqueness for each root level class

Parameters

$sibling_classes

arrayarray of classes to check

Returns

booleantrue means no clashes, false means clash.

_name_is_unique_check_siblings (array $sibling_classes, $parent)

Helper for name_is_unique, checks uniqueness for each sibling

Parameters

$sibling_classes

arrayarray of classes to check

$parent

Returns

booleantrue means no clashes, false means clash.

_parse_filename ($name, $extension, $default)

Parameters

$name

$extension

$default

 Properties

 

\midcom_core_dbaobject $_object

The object we're working with