Alpha Framework 3.1.0 API Documentation

Relation extends Type implements TypeInterface

The Relation complex data type.

Tags
since
1.0
author

John Collins dev@alphaframework.org

license

http://www.opensource.org/licenses/bsd-license.php The BSD License

copyright

Copyright (c) 2018, John Collins (founder of Alpha Framework). All rights reserved.

Redistribution and use in source and binary forms, with or
without modification, are permitted provided that the
following conditions are met:

* Redistributions of source code must retain the above
  copyright notice, this list of conditions and the
  following disclaimer.
* Redistributions in binary form must reproduce the above
  copyright notice, this list of conditions and the
  following disclaimer in the documentation and/or other
  materials provided with the distribution.
* Neither the name of the Alpha Framework nor the names
  of its contributors may be used to endorse or promote
  products derived from this software without specific
  prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Interfaces, Classes and Traits

TypeInterface
The interface for all complex data types.

Table of Contents

MAX_SIZE  = 11
The absolute maximum size of the value for the this Relation.
$helper  : string
The error message for the Relation type when validation fails.
$allowableRelationTypes  : array<string|int, mixed>
An array of the allowable relationship types ('MANY-TO-ONE' or 'ONE-TO-MANY' or 'ONE-TO-ONE' or 'MANY-TO-MANY').
$IDs  : array<string|int, mixed>
In the case of MANY-TO-MANY relationship, this transient array can be used to hold the IDs of related records.
$lookup  : RelationLookup
In the case of MANY-TO-MANY relationship, a lookup object will be required.
$relatedClass  : string
The name of the business object class which this class is related to.
$relatedClassDisplayField  : string
The name of the field from the related business object class which is displayed by the selection widget.
$relatedClassField  : string
The name of the fields of the business object class by which this class is related by.
$relatedClassHeaderFields  : array<string|int, mixed>
An array of fields to use the values of while rendering related display values via the selection widget.
$relatedClassLeft  : string
The name of the business object class on the left of a MANY-TO-MANY relation.
$relatedClassLeftDisplayField  : string
The name of the field from the related business object class on the left of a MANY-TO-MANY relation which is displayed by the selection widget.
$relatedClassRight  : string
The name of the business object class on the right of a MANY-TO-MANY relation.
$relatedClassRightDisplayField  : string
The name of the field from the related business object class on the right of a MANY-TO-MANY relation which is displayed by the selection widget.
$relationType  : string
The type of relation ('MANY-TO-ONE' or 'ONE-TO-MANY' or 'ONE-TO-ONE' or 'MANY-TO-MANY').
$size  : int
The size of the value for the this Relation.
$taggedClass  : string
When building a relation with the TagObject record, set this to the name of the tagged class.
$validationRule  : string
The validation rule for the Relation type.
$value  : mixed
The ID value of the related object. In the special case of a MANY-TO-MANY relation, contains the ID of the object on the current, accessing side. Can contain NULL.
__construct()  : mixed
Constructor.
__toString()  : string
Used to convert the object to a printable string.
getHelper()  : string
Used to get the validation helper message string.
getLookup()  : RelationLookup
Get the lookup object if available (only on MANY-TO-MANY relations, null otherwise).
getRelated()  : array<string|int, mixed>|ActiveRecord
For one-to-many and many-to-many relations, get an array of records on the other side. For one-to-one relations, get the record (Alpha\Model\ActiveRecord instance) on the other side.
getRelatedClass()  : string
Get the name of the business object class that this class is related to.
getRelatedClassDisplayField()  : string
Getter for the display field from the related class.
getRelatedClassDisplayFieldValue()  : string
Getter for the display value of the related class field. In the case of a MANY-TO-MANY Relation, a comma-seperated sorted list of values is returned.
getRelatedClassField()  : string
Getter for the field of the related class.
getRelatedClassHeaderFields()  : array<string|int, mixed>
Getter for the selection widget field headings of the related class.
getRelatedIDs()  : array<string|int, mixed>
Getter for the array of IDs used by MANY-TO-MANY instances.
getRelationType()  : string
Getter for the relation type.
getRule()  : string
Get the validation rule.
getSide()  : string
Gets the side ('left' or 'right') of the passed classname on the current Relation object.
getSize()  : int
Get the allowable size of the Relation in the database field.
getValue()  : string
Getter for the Relation value.
setHelper()  : mixed
Set the validation helper text.
setRelatedClass()  : mixed
Set the name of the business object class that this class is related to.
setRelatedClassDisplayField()  : mixed
Setter for the display field from the related class.
setRelatedClassField()  : mixed
Setter for the field of the related class.
setRelatedClassHeaderFields()  : mixed
Setter for ONE-TO-MANY relations, which sets the header fields to render from the related class.
setRelatedIDs()  : mixed
Setter for the array of IDs used by MANY-TO-MANY instances.
setRelationType()  : mixed
Setter for the relation type.
setRule()  : mixed
Setter to override the default validation rule.
setTaggedClass()  : mixed
Set the taggedClass property to the name of the tagged class when building relations to the TagObject record.
setValue()  : mixed
Setter for the value ID of this relation.

Constants

MAX_SIZE

The absolute maximum size of the value for the this Relation.

public int MAX_SIZE = 11
Tags
since
1.0

Properties

$helper

The error message for the Relation type when validation fails.

protected string $helper
Tags
since
1.0

$allowableRelationTypes

An array of the allowable relationship types ('MANY-TO-ONE' or 'ONE-TO-MANY' or 'ONE-TO-ONE' or 'MANY-TO-MANY').

private array<string|int, mixed> $allowableRelationTypes = array('MANY-TO-ONE', 'ONE-TO-MANY', 'ONE-TO-ONE', 'MANY-TO-MANY')
Tags
since
1.0

$IDs

In the case of MANY-TO-MANY relationship, this transient array can be used to hold the IDs of related records.

private array<string|int, mixed> $IDs = array()
Tags
since
2.0

$lookup

In the case of MANY-TO-MANY relationship, a lookup object will be required.

private RelationLookup $lookup
Tags
since
1.0

$relatedClass

The name of the business object class which this class is related to.

private string $relatedClass
Tags
since
1.0

$relatedClassDisplayField

The name of the field from the related business object class which is displayed by the selection widget.

private string $relatedClassDisplayField
Tags
since
1.0

$relatedClassField

The name of the fields of the business object class by which this class is related by.

private string $relatedClassField
Tags
since
1.0

$relatedClassHeaderFields

An array of fields to use the values of while rendering related display values via the selection widget.

private array<string|int, mixed> $relatedClassHeaderFields = array()
Tags
since
1.0

$relatedClassLeft

The name of the business object class on the left of a MANY-TO-MANY relation.

private string $relatedClassLeft
Tags
since
1.0

$relatedClassLeftDisplayField

The name of the field from the related business object class on the left of a MANY-TO-MANY relation which is displayed by the selection widget.

private string $relatedClassLeftDisplayField
Tags
since
1.0

$relatedClassRight

The name of the business object class on the right of a MANY-TO-MANY relation.

private string $relatedClassRight
Tags
since
1.0

$relatedClassRightDisplayField

The name of the field from the related business object class on the right of a MANY-TO-MANY relation which is displayed by the selection widget.

private string $relatedClassRightDisplayField
Tags
since
1.0

$relationType

The type of relation ('MANY-TO-ONE' or 'ONE-TO-MANY' or 'ONE-TO-ONE' or 'MANY-TO-MANY').

private string $relationType
Tags
since
1.0

$size

The size of the value for the this Relation.

private int $size = 11
Tags
since
1.0

$taggedClass

When building a relation with the TagObject record, set this to the name of the tagged class.

private string $taggedClass
Tags
since
1.0

$validationRule

The validation rule for the Relation type.

private string $validationRule
Tags
since
1.0

$value

The ID value of the related object. In the special case of a MANY-TO-MANY relation, contains the ID of the object on the current, accessing side. Can contain NULL.

private mixed $value = null
Tags
since
1.0

Methods

__construct()

Constructor.

public __construct() : mixed
Tags
since
1.0
Return values
mixed

__toString()

Used to convert the object to a printable string.

public __toString() : string
Tags
since
1.0
Return values
string

getHelper()

Used to get the validation helper message string.

public getHelper() : string
Tags
since
1.0
Return values
string

getLookup()

Get the lookup object if available (only on MANY-TO-MANY relations, null otherwise).

public getLookup() : RelationLookup
Tags
since
1.0
Return values
RelationLookup

getRelated()

For one-to-many and many-to-many relations, get an array of records on the other side. For one-to-one relations, get the record (Alpha\Model\ActiveRecord instance) on the other side.

public getRelated([mixed $accessingClassName = '' ]) : array<string|int, mixed>|ActiveRecord

string $accessingClassName Used to indicate the reading side when accessing from MANY-TO-MANY relation (leave blank for other relation types)

Parameters
$accessingClassName : mixed = ''
Tags
since
3.0
throws
IllegalArguementException
Return values
array<string|int, mixed>|ActiveRecord

getRelatedClass()

Get the name of the business object class that this class is related to.

public getRelatedClass([string $side = '' ]) : string
Parameters
$side : string = ''
Tags
since
1.0
throws
IllegalArguementException
Return values
string

getRelatedClassDisplayField()

Getter for the display field from the related class.

public getRelatedClassDisplayField([string $side = '' ]) : string
Parameters
$side : string = ''

Only required for MANY-TO-MANY relations

Tags
since
1.0
throws
IllegalArguementException
Return values
string

getRelatedClassDisplayFieldValue()

Getter for the display value of the related class field. In the case of a MANY-TO-MANY Relation, a comma-seperated sorted list of values is returned.

public getRelatedClassDisplayFieldValue([string $accessingClassName = '' ]) : string
Parameters
$accessingClassName : string = ''

Used to indicate the reading side when accessing from MANY-TO-MANY relation (leave blank for other relation types)

Tags
since
1.0
throws
IllegalArguementException
Return values
string

getRelatedClassField()

Getter for the field of the related class.

public getRelatedClassField() : string
Tags
since
1.0
Return values
string

getRelatedClassHeaderFields()

Getter for the selection widget field headings of the related class.

public getRelatedClassHeaderFields() : array<string|int, mixed>
Tags
since
1.0
Return values
array<string|int, mixed>

getRelatedIDs()

Getter for the array of IDs used by MANY-TO-MANY instances.

public getRelatedIDs() : array<string|int, mixed>
Tags
since
2.0
Return values
array<string|int, mixed>

getRelationType()

Getter for the relation type.

public getRelationType() : string
Tags
since
1.0
Return values
string

getRule()

Get the validation rule.

public getRule() : string
Tags
since
1.0
Return values
string

getSide()

Gets the side ('left' or 'right') of the passed classname on the current Relation object.

public getSide(string $RecordClassname) : string
Parameters
$RecordClassname : string
Tags
since
1.0
throws
IllegalArguementException
Return values
string

getSize()

Get the allowable size of the Relation in the database field.

public getSize() : int
Tags
since
1.0
Return values
int

getValue()

Getter for the Relation value.

public getValue() : string
Tags
since
1.0
Return values
string

setHelper()

Set the validation helper text.

public setHelper(string $helper) : mixed
Parameters
$helper : string
Tags
since
1.0
Return values
mixed

setRelatedClass()

Set the name of the business object class that this class is related to.

public setRelatedClass(string $RC[, string $side = '' ]) : mixed
Parameters
$RC : string
$side : string = ''

Only required for MANY-TO-MANY relations

Tags
since
1.0
throws
IllegalArguementException
Return values
mixed

setRelatedClassDisplayField()

Setter for the display field from the related class.

public setRelatedClassDisplayField(string $RCDF[, string $side = '' ]) : mixed
Parameters
$RCDF : string
$side : string = ''

Only required for MANY-TO-MANY relations

Tags
since
1.0
throws
IllegalArguementException
Return values
mixed

setRelatedClassField()

Setter for the field of the related class.

public setRelatedClassField(string $RCF) : mixed
Parameters
$RCF : string
Tags
since
1.0
throws
IllegalArguementException
Return values
mixed

setRelatedClassHeaderFields()

Setter for ONE-TO-MANY relations, which sets the header fields to render from the related class.

public setRelatedClassHeaderFields(array<string|int, mixed> $fieldNames) : mixed
Parameters
$fieldNames : array<string|int, mixed>
Tags
since
1.0
Return values
mixed

setRelatedIDs()

Setter for the array of IDs used by MANY-TO-MANY instances.

public setRelatedIDs(array<string|int, mixed> $IDs) : mixed
Parameters
$IDs : array<string|int, mixed>
Tags
since
2.0
throws
IllegalArguementException
Return values
mixed

setRule()

Setter to override the default validation rule.

public setRule(string $rule) : mixed
Parameters
$rule : string
Tags
since
1.0
Return values
mixed

setTaggedClass()

Set the taggedClass property to the name of the tagged class when building relations to the TagObject record.

public setTaggedClass(string $taggedClass) : mixed
Parameters
$taggedClass : string
Tags
since
1.0
Return values
mixed

setValue()

Setter for the value ID of this relation.

public setValue(int $val) : mixed
Parameters
$val : int
Tags
since
1.0
throws
IllegalArguementException
Return values
mixed

Search results