com\setasign\Konquadrat\Object

ObjectSet Class ObjectSet

File: /Konquadrat/src/Object/ObjectSet.php

Class hierarchy

Implements

Summary

Properties

$actualScope

protected int[] AbstractObjectSet::$actualScope = array()

The ids of the actual run throw

$childFinder

$filter

private ObjectSet::$filter

$id

private ObjectSet::$id

Unique ObjectSet id

$instancePoolManager

$magicResolver

$magicWithParamResolver

$objectConfig

$objectData

protected array<int, array> AbstractObjectSet::$objectData = array()

Array with all objectData from this objectSet

Key => id
Value => data

$objectFactory

$objectFinder

$objectSetFactory

$permissionControl

$position

Cursor for the iterator

$referenceFinder

$referencing

protected AbstractObjectSet::$referencing = array()

Array with information about referencing objects

  • Key => reference target id
  • Value => Array:
    • Key => Type
    • Value => Array:
      • Key => Field
      • Value => Array(ids)

$referencingObjectsFinder


Methods

__construct()

public ObjectSet::__construct (
ObjectSet\ObjectSetFactoryInterface $objectSetFactory,
ObjectSet\ReferenceFinder $referenceFinder,
ObjectSet\ChildFinder $childFinder,
ObjectSet\MagicResolver $magicResolver,
ObjectSet\MagicWithParamResolver $magicWithParamResolver,
ObjectSet\ReferencingObjectsFinder $referencingObjectsFinder,
ObjectSet\Filter $filter,
ObjectSet\Sorter $sorter,
ObjectSet\Reloader $reloader,
ObjectConfig $objectConfig,
ObjectFinder $objectFinder,
ObjectFactoryInterface $objectFactory,
InstancePoolManager $instancePoolManager,
?\com\setasign\Konquadrat\Permission\PermissionControl $permissionControl = null,
array $data = array ( )
)

ObjectSet constructor.

Parameters
$objectSetFactory : ObjectSet\ObjectSetFactoryInterface
 
$referenceFinder : ObjectSet\ReferenceFinder
 
$childFinder : ObjectSet\ChildFinder
 
$magicResolver : ObjectSet\MagicResolver
 
$magicWithParamResolver : ObjectSet\MagicWithParamResolver
 
$referencingObjectsFinder : ObjectSet\ReferencingObjectsFinder
 
$filter : ObjectSet\Filter
 
$sorter : ObjectSet\Sorter
 
$reloader : ObjectSet\Reloader
 
$objectConfig : ObjectConfig
 
$objectFinder : ObjectFinder
 
$objectFactory : ObjectFactoryInterface
 
$instancePoolManager : InstancePoolManager
 
$permissionControl : ?\com\setasign\Konquadrat\Permission\PermissionControl
 
$data : array
 

__sleep()

public AbstractObjectSet::__sleep (
void
): void

count()

public AbstractObjectSet::count (
void
): int

(PHP 5 >= 5.1.0)
Count elements of an object

Return Values

The custom count as an integer.

The return value is cast to an integer.

current()

public ObjectSet::current (
void
): ?mixed

Return the current element

filter()

getActualScope()

public AbstractObjectSet::getActualScope (
void
): array

Returns the object ids of the objects in the actual scope.

getById()

public ObjectSet::getById (
int $id,
?class-string<expectedType> $expectedType = null,
bool $onlyExisting = false
): AbstractObject|expectedType

Return the AbstractObject with the id $id.

If the objectId is unknown for the ObjectSet it will redirect the call to ObjectFinder::getById().

The returned ObjectSet is connected with this ObjectSet.

Parameters
$id : int
 
$expectedType : ?class-string<expectedType>

The expected object type.

$onlyExisting : bool

If set to true the call will not be directed to the objectFinder.

Exceptions

Throws UnknownObjectException If the type doesn't match.

getChilds()

public ObjectSet::getChilds (
null|string|string[] $types = null
): ObjectSet

Return an ObjectSet with all known childs of the objects in the actual scope.

It is necessary to previously call withChilds otherwise the returned ObjectSet will be empty.

The returned ObjectSet is connected with this ObjectSet.

Parameters
$types : null|string|string[]
 

getId()

public ObjectSet::getId (
void
): string

getParentIds()

public AbstractObjectSet::getParentIds (
void
): array

getParents()

public ObjectSet::getParents (
void
): ObjectSet

Return an ObjectSet with all known parents of the objects in the actual scope.

It is necessary to previously call withParents otherwise the returned ObjectSet will be empty.

The returned ObjectSet is connected with this ObjectSet.

getReferenceIds()

public AbstractObjectSet::getReferenceIds (
array|string|null $fieldNames = null,
bool $validateFieldNames = true
): array
Parameters
$fieldNames : array|string|null
 
$validateFieldNames : bool
 

getReferences()

public ObjectSet::getReferences (
?array $fieldNames = null
): ObjectSet

Return an ObjectSet with all known references of the objects in the actual scope.

It is necessary to previously call withReferences otherwise the returned ObjectSet will be empty.

The returned ObjectSet is connected with this ObjectSet.


The $fieldNames array need to look like this:
$fieldNames = [
    'EventRelation' => ['Event', 'parent'],
    'Event', // load all references of containing event objects
];
Parameters
$fieldNames : ?array
 

getReferencingObjects()

public ObjectSet::getReferencingObjects (
string $type,
string $field
): ObjectSet

Get all objects of $type that are referencing on any object of the actual scope over the reference field $field.

Parameters
$type : string
 
$field : string
 

getTypes()

public AbstractObjectSet::getTypes (
void
): array

Returns the object types of all objects in the actual scope. Every type is only once in the result.

hasChilds()

public ObjectSet::hasChilds (
null|string|string[] $types = null
): bool
Parameters
$types : null|string|string[]
 

hasObject()

public ObjectSet::hasObject (
int $id,
bool $onlyExisting = false
): bool

Checks whether the object is inside the objectSet.

Note: Doesn't check whether the object is inside the actual scope!

Parameters
$id : int
 
$onlyExisting : bool

If true the object must be within this object set.

hasReferencingObjects()

public AbstractObjectSet::hasReferencingObjects (
string $type,
string $field
): bool
Parameters
$type : string
 
$field : string
 

key()

public AbstractObjectSet::key (
void
): ?int

(PHP 5 >= 5.0.0)
Return the key of the current element

Return Values

scalar on success, or null on failure.

limit()

public AbstractObjectSet::limit (
int $limit,
?int $offset = null
): self
Parameters
$limit : int
 
$offset : ?int
 

next()

public AbstractObjectSet::next (
void
): void

(PHP 5 >= 5.0.0)
Move forward to next element

Return Values

Any returned value is ignored.

order()

public AbstractObjectSet::order (
string|array|callable $orders
): self
Parameters
$orders : string|array|callable
 
See

reload()

public AbstractObjectSet::reload (
void
): static

Reload all objects in the actual scope.

Exceptions

Throws UnknownObjectException If (at least) one object can't be found!

resolveMagic()

public ObjectSet::resolveMagic (
?array $fieldNames = null
): self
Parameters
$fieldNames : ?array
 
See

resolveMagicWithParam()

public ObjectSet::resolveMagicWithParam (
array $fieldNames
): self
Parameters
$fieldNames : array
 
See

rewind()

public AbstractObjectSet::rewind (
void
): void

(PHP 5 >= 5.0.0)
Rewind the Iterator to the first element

Return Values

Any returned value is ignored.

setActualScope()

public ObjectSet::setActualScope (
int[] $ids,
bool $newObject = false
): ObjectSet
Parameters
$ids : int[]
 
$newObject : bool

Defines whether a new object set instance will be created

toArray()

WARNING: This method is marked as deprecated!

Use toDataArray() or toObjectArray() instead

public AbstractObjectSet::toArray (
bool $asObject = false
): array

Returns the actual scope as array.

If $asObject is false the result will be an array filled with associative arrays. If $asObject is true the result will be an array filled with AbstractObjects.

Parameters
$asObject : bool
 

toDataArray()

public AbstractObjectSet::toDataArray (
void
): array

toObjectArray()

public ObjectSet::toObjectArray (
void
): array

Returns the actual scope as an array ob AbstractObjects.

valid()

public AbstractObjectSet::valid (
void
): bool

(PHP 5 >= 5.0.0)
Checks if current position is valid

Return Values

The return value will be cast to boolean and then evaluated. Returns true on success or false on failure.

withAllChilds()

public ObjectSet::withAllChilds (
string|string[]|null $types = null
): self

This method will load all objects below the actual scope via the path.

Parameters
$types : string|string[]|null
 
See

withChilds()

public ObjectSet::withChilds (
string|string[]|null $types = null,
null $selectors = null
): ObjectSet\ResolveHelper
Parameters
$types : string|string[]|null
 
$selectors : null
 
See

withParents()

withReferences()

public ObjectSet::withReferences (
?array $fieldNames = null
): ObjectSet\ResolveHelper
Parameters
$fieldNames : ?array
 
See

withReferencingObjects()

public ObjectSet::withReferencingObjects (
string $type,
string $field
): ObjectSet\ResolveHelper
Parameters
$type : string
 
$field : string