com\setasign\Konquadrat\Object

ObjectFinder Describes a logger-aware instance.

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

Class hierarchy

Implements

  • \Psr\Log\LoggerAwareInterface

Summary

Properties

$database

$gridFactory

$instancePoolManager

$languageManager

$logger

protected ?\Psr\Log\LoggerInterface ObjectFinder::$logger

$objectConfig

$objectFactory

$objectSetFactory

$objectTableManager

$permissionControl

Note: The permission control is only set in backend mode.

$sessionContext

Note: The session context is only set in backend mode.

$showDeleted

protected ?bool ObjectFinder::$showDeleted = false

Will be null if a temporary flag is set


Methods

buildSelect()

Builds an tableSelect for the matching $selector phrase.

Parameters
$selector: Selector
 

createObjectSet()

public ObjectFinder::createObjectSet (
array $objectsData
): ObjectSet

Creates an objectSet.

Parameters
$objectsData: array
 

createObjectSetByArray()

get()

WARNING: This method is marked as deprecated!

Use getSet() or getSingleObject() instead. Note: getSingleObject will throw an exception if nothing is found!

public ObjectFinder::get (
Selector<T> $selector
): ObjectSet<T>|T|AbstractObject|null

Get one or multiple objects which match on the given objectSelector.

Templates
T of AbstractObjectInterface
Parameters
$selector: Selector<T>
 
Return Values

AbstractObject or null will be returned if $limit is 1. Otherwise, an ObjectSet will be returned.

getAllReferencingObjects()

public ObjectFinder::getAllReferencingObjects (
int|int[]|AbstractObjectSet $ids,
bool $recursive = true,
bool $ignoreDeletedObjects = true
): bool|array

Check for references pointing on the object(s).

Warning: This method should be used with care because it can need some time and database performance.

Parameters
$ids: int|int[]|AbstractObjectSet
 
$recursive: bool
 
$ignoreDeletedObjects: bool

We ignore deleted objects otherwise objects with deleted childs which require a parent will never be deletable

Return Values

False if no referencing objects found

getById()

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

Gets an object by id.

This method uses the instance from the objectFactory if possible.

Templates
T of AbstractObjectInterface
Parameters
$id: int
 
$expectedType: ?class-string<T>
 
$smart: bool

If true the object will be loaded from a smart object set.

Exceptions

Throws UnknownObjectException

getByName()

public ObjectFinder::getByName (
string $name,
?class-string<T> $expectedType = null,
bool $smart = false
): AbstractObject|Custom\NamedObjectObject

Gets an object by name (only for namedObjects).

Templates
T of AbstractObjectInterface
Parameters
$name: string
 
$expectedType: ?class-string<T>
 
$smart: bool

If true the object will be loaded from a smart object set.

Exceptions

Throws UnknownObjectException

getByUuid()

public ObjectFinder::getByUuid (
string $uuid,
?class-string<T> $expectedType = null,
bool $smart = false
): AbstractObject

Gets an object by uuid.

Templates
T of AbstractObjectInterface
Parameters
$uuid: string
 
$expectedType: ?class-string<T>
 
$smart: bool

If true the object will be loaded from a smart object set.

Exceptions

Throws UnknownObjectException

getChilds()

public ObjectFinder::getChilds (
int|int[] $parentIds,
null|string|string[] $onlyTypes = null,
?ObjectSet $objectSet = null
): ObjectSet

Get all childs for one or multiple objects.

Parameters
$parentIds: int|int[]
 
$onlyTypes: null|string|string[]
 
$objectSet: ?ObjectSet

Only for internal use! The resulting ObjectSet will be linked with this ObjectSet.

getCount()

public ObjectFinder::getCount (
Selector $selector
): int
Parameters
$selector: Selector
 

getDataById()

public ObjectFinder::getDataById (
int $id,
?string $expectedType = null
): array

Gets the data of an object by id.

This method doesn't use the objectFactory and should be used with care.

Parameters
$id: int
 
$expectedType: ?string

The expected object type. The method will not check whether the object is really an object of this type, it is only used to build the joinedTable! It is only used if the type is a final object type.

Exceptions

Throws UnknownObjectException

getReferencingObjects()

public ObjectFinder::getReferencingObjects (
int|int[] $ids,
string $type,
string $field,
?ObjectSet $objectSet = null
): ObjectSet

Get all objects of $type that are referencing on an object of $ids over the reference field $field.

Parameters
$ids: int|int[]
 
$type: string
 
$field: string
 
$objectSet: ?ObjectSet

Only for internal use! The resulting ObjectSet will be linked with this ObjectSet.

getSet()

public ObjectFinder::getSet (
Selector<T> $selector
): ObjectSet<T>
Templates
T of AbstractObjectInterface
Parameters
$selector: Selector<T>
 

getShowDeleted()

public ObjectFinder::getShowDeleted (
void
): bool

Get the status of the "show deleted"-flag. The flag is false by default.

When used in Backend the flag in the session will only be used if the user has the AdminPermission::PERMISSION_ACTION_SHOW_DELETED.

getSingleObject()

public ObjectFinder::getSingleObject (
Selector<T> $selector,
bool $smart = false
): T
Templates
T of AbstractObjectInterface
Parameters
$selector: Selector<T>
 
$smart: bool

If true the object will be loaded from a smart object set.

Exceptions

Throws UnknownObjectException

getSmartSet()

public ObjectFinder::getSmartSet (
Selector<T> $selector
): SmartObjectSet<T>

Get one or multiple objects which match on the given objectSelector.

Returns a smart object set.

The main differences between normal object sets and smart object sets is that the smart object set doesn't provide methods to eager load other objects related to the object in this set. Instead of this it will load the required objects by itself. The main draw back for this is that the smart set will never use the instance pool and will ALWAYS load objects from the database if they aren't in this object set.

A smart object set is meant for usage in foreach loops with one time usage of every object instance and isn't meant for any other use-case!

Templates
T of AbstractObjectInterface
Parameters
$selector: Selector<T>
 
See

setLogger()

public ObjectFinder::setLogger (
\Psr\Log\LoggerInterface $logger
): void

Sets a logger instance on the object.

Parameters
$logger: \Psr\Log\LoggerInterface
 

setSessionContext()

setShowDeleted()

public ObjectFinder::setShowDeleted (
bool $show = true,
bool $temporary = true
): void

Set the status of the "show deleted"-flag.

Note: switching the flag on runtime should be used with care. ObjectSet and InstancePool might behave strange.

Parameters
$show: bool

Status whether to show the deleted

$temporary: bool

If false the status will be saved in the actual session.