com\setasign\Konquadrat\Object

AbstractObject Class AbstractObject

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

Class hierarchy

Implements

Summary

Constants

ACTION_DELETE

public const AbstractObjectInterface::ACTION_DELETE = 'delete'

ACTION_READ

public const AbstractObjectInterface::ACTION_READ = 'read'

ACTION_WRITE

public const AbstractObjectInterface::ACTION_WRITE = 'write'

EVENT_AFTER_SAVE

public const AbstractObject::EVENT_AFTER_SAVE = 'afterSave'

Event is triggered after save

params:

  • $this
  • array $changes

EVENT_AFTER_SAVE_AND_COMMIT

public const AbstractObject::EVENT_AFTER_SAVE_AND_COMMIT = 'afterSaveAndCommit'

Event is triggered after save and after the current transaction is committed.

params:

  • $this
  • array $changes

EVENT_AFTER_SAVE_AND_ROLLBACK

public const AbstractObject::EVENT_AFTER_SAVE_AND_ROLLBACK = 'afterSaveAndRollback'

Event is triggered after save and after the current transaction is rolled back.

params:

  • $this
  • ?array $changes

EVENT_AFTER_SAVE_ERROR

public const AbstractObject::EVENT_AFTER_SAVE_ERROR = 'afterSaveError'

Event is triggered while saving if something went wrong

params:

  • $this
  • Throwable $exception

EVENT_BEFORE_SAVE

public const AbstractObject::EVENT_BEFORE_SAVE = 'beforeSave'

Event is triggered before save

params:

  • $this
  • bool $force

EVENT_CREATE

public const AbstractObject::EVENT_CREATE = 'create'

Event is triggered on creation of a new object (before the first save)

params:

  • $this

NAME

public const AbstractObjectInterface::NAME = 'AbstractObject'

Properties

$actionResolver

$data

protected array AbstractObject::$data = array()

$documentResolver

$events

private callable[][] AbstractObject::$events = array()

$fieldFactory

$fieldsConfig

Fields config

$isSettingData

Will be true when the data from the database will be inserted into the object.

For the most set-methods you will need to react on this.

See

$languageManager

$logger

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

$objectConfig

$objectFinder

$objectManager

$resourceDefinitionManager

$sleep

protected array AbstractObject::$sleep

All properties which should be serialized.

Note: Private properties cannot be serialized!

$transactionManager


Methods

__construct()

public AbstractObject::__construct (
ObjectConfig $objectConfig,
ObjectFinder $objectFinder,
ObjectManager $objectManager,
TransactionManager $transactionManager,
\com\setasign\Konquadrat\LanguageManager $languageManager,
\com\setasign\Konquadrat\Field\FieldFactory\FieldFactoryInterface $fieldFactory,
DocumentResolverInterface $documentResolver,
ActionResolverInterface $actionResolver,
\com\setasign\Konquadrat\Permission\ResourceDefinitionManager $resourceDefinitionManager,
InitTraitResolverInterface $initTraitResolver,
WakeupObjectResolverInterface $wakeupResolver,
array $data,
?Scope\ScopeInterface $objectScope = null
)
Parameters
$objectConfig : ObjectConfig
 
$objectFinder : ObjectFinder
 
$objectManager : ObjectManager
 
$transactionManager : TransactionManager
 
$languageManager : \com\setasign\Konquadrat\LanguageManager
 
$fieldFactory : \com\setasign\Konquadrat\Field\FieldFactory\FieldFactoryInterface
 
$documentResolver : DocumentResolverInterface
 
$actionResolver : ActionResolverInterface
 
$resourceDefinitionManager : \com\setasign\Konquadrat\Permission\ResourceDefinitionManager
 
$initTraitResolver : InitTraitResolverInterface
 
$wakeupResolver : WakeupObjectResolverInterface
 
$data : array
 
$objectScope : ?Scope\ScopeInterface
 
Exceptions

Throws \com\setasign\Konquadrat\Exception

__call()

public AbstractObject::__call (
string $name,
array $arguments
): ?mixed

Give some magic methods:

  • getField{$fieldName}() -> Alias for getField($fieldName)
  • getChild{$objectType}Objects() -> Alias for getChilds($objectType)
  • getReferencing{$objectType}ObjectsBy{$fieldName}Field() -> Alias for getReferencingObjects($objectType, $fieldName)
Parameters
$name : string
 
$arguments : array
 

__clone()

public AbstractObject::__clone (
void
): void
Exceptions

Throws \com\setasign\Konquadrat\Exception

__get()

public AbstractObject::__get (
string $fieldName
): ?mixed

Alias for get($fieldName, true)

Parameters
$fieldName : string
 
Exceptions

Throws MissingConfigurationException

See

__isset()

public AbstractObject::__isset (
string $fieldName
): bool

Checks whether $fieldName exists and the value is not null.

Parameters
$fieldName : string
 

__set()

public AbstractObject::__set (
string $fieldName,
mixed $value
): void

Alias for set($fieldName, $value)

Parameters
$fieldName : string
 
$value : mixed
 
See

__sleep()

final public AbstractObject::__sleep (
void
): array

__wakeup()

final public AbstractObject::__wakeup (
void
): void
Exceptions

Throws \Throwable

addEventListener()

final public AbstractObject::addEventListener (
string $eventName,
string $name,
callable $callback
): void
Parameters
$eventName : string
 
$name : string

The name of this callback. The name is only unique for this method & object.

$callback : callable
 

callAction()

final public AbstractObject::callAction (
string $action,
array $additionalArguments = array ( )
): ?Action\ActionResponse
Parameters
$action : string
 
$additionalArguments : array
 
Exceptions

Throws \InvalidArgumentException If the action is unknown.

copyObjectData()

final public AbstractObject::copyObjectData (
AbstractObjectInterface $object,
null|string|string[] $onlyTypes = null
): AbstractObjectInterface

Copy the data of $object into this object. All fields of AbstractObject will be ignored (including the parent).

Parameters
$object : AbstractObjectInterface
 
$onlyTypes : null|string|string[]
 

create()

private AbstractObject::create (
void
): void

The method will be called when a new object is created.

delete()

public AbstractObject::delete (
bool $recursive = true
): array

Marks the object as deleted and saves the object.

Existing references will not be unlinked, but you could find these objects with ObjectFinder::getReferencingObjects()!

This method will create a transaction if no transaction is active and revert everything if an error is thrown.

Parameters
$recursive : bool

Delete also all childs.

Return Values

Array with the ids of all deleted objects.

Exceptions

Throws \Throwable

get()

final public AbstractObject::get (
string $fieldName,
bool $resolve = true
): ?mixed

Get the value of $fieldName.

Parameters
$fieldName : string
 
$resolve : bool

Resolve resolvable fields like reference and json fields.

getAs()

final public AbstractObject::getAs (
string $name
): \com\setasign\SetaFramework\FileSystem\File

Get the object as document of type $name

Parameters
$name : string
 
Exceptions

Throws \InvalidArgumentException If the name is invalid!

getChanged()

final public AbstractObject::getChanged (
void
): array

getChilds()

final public AbstractObject::getChilds (
null|class-string<T>|string[] $type = null
): ObjectSet<T>|SmartObjectSet<T>
Parameters
$type : null|class-string<T>|string[]
 

getData()

final public AbstractObject::getData (
bool $resolveMagicFields = true
): array

Returns the data of the fields of this object.

MultiLangString, MultiLangText and Password fields are ignored.

Parameters
$resolveMagicFields : bool
 

getField()

Gets the field instance of $fieldName.

Parameters
$fieldName : string
 
Exceptions

Throws MissingConfigurationException If the field isn't configured.

getFieldContainerName()

final public AbstractObject::getFieldContainerName (
void
): string

getFields()

final public AbstractObject::getFields (
void
): array

Get all fields

getInitialData()

final public AbstractObject::getInitialData (
void
): array

getMagicWithParam()

final public AbstractObject::getMagicWithParam (
string $fieldName,
array $parameters
): string
Parameters
$fieldName : string
 
$parameters : array
 

getPath()

final public AbstractObject::getPath (
void
): string

getPermissionResource()

final public AbstractObject::getPermissionResource (
void
): \com\setasign\SetaFramework\Permissions\ResourceDefinition

getReferencingObjects()

final public AbstractObject::getReferencingObjects (
class-string<T> $type,
string $field
): ObjectSet<T>|SmartObjectSet<T>
Parameters
$type : class-string<T>
 
$field : string
 

getTabHeader()

public AbstractObject::getTabHeader (
void
): string

Get the text header which will be shown in the gui.

hasAction()

final public AbstractObject::hasAction (
string $action
): bool
Parameters
$action : string
 

hasDocument()

final public AbstractObject::hasDocument (
string $name
): bool
Parameters
$name : string
 

hasField()

final public AbstractObject::hasField (
string $fieldName
): bool

Checks whether the object has the field $fieldName.

Parameters
$fieldName : string
 

isSettingData()

public AbstractObject::isSettingData (
void
): bool

Will be true when the data from the database will be inserted into the object.

For the most set-methods you will need to react on this.

reload()

final public AbstractObject::reload (
void
): void

Reloads the object.

All changed data will be reset!!

Exceptions

Throws \BadMethodCallException If the object was never saved!

Throws UnknownObjectException If the object cannot be found!

removeEventListener()

final public AbstractObject::removeEventListener (
string $eventName,
string $name
): void
Parameters
$eventName : string
 
$name : string
 

resetField()

final public AbstractObject::resetField (
string $fieldName
): void

Resets the field to the initial value.

Parameters
$fieldName : string
 

save()

final public AbstractObject::save (
bool $force = false
): AbstractObject

Save the object.

Parameters
$force : bool

Save everytime no matter whether there was a change

Exceptions

Throws ObjectSaveException If an error occurs during the save process.

set()

final public AbstractObject::set (
string $fieldName,
mixed|\com\setasign\Konquadrat\Field\DefaultValue $value
): static

Sets the value for the field.

Parameters
$fieldName : string
 
$value : mixed|\com\setasign\Konquadrat\Field\DefaultValue
 

setData()

final public AbstractObject::setData (
array $data,
bool $ignoreMissingFields = false
): void

Set multiple fields at once.

Parameters
$data : array
 
$ignoreMissingFields : bool

If true unknown fields will just be ignored.

setLogger()

final public AbstractObject::setLogger (
\Psr\Log\LoggerInterface $logger
): void
Parameters
$logger : \Psr\Log\LoggerInterface