ModelVersion
extends BaseModel
in package
uses
WithOwnerTrait
Model Version Model
Table of Contents
Properties
- $table_name : string|null
- $db_row : Row
- $is_first_save : bool
- $keyField : string|array<string|int, mixed>
- $loadedObjects : array<string|int, mixed>
- $original_data : array<string|int, mixed>|null
Methods
- __call() : mixed
- {@inheritdoc}
- __callStatic() : mixed
- {@inheritdoc}
- __construct() : mixed
- {@inheritdoc}
- __get() : mixed
- {@inheritdoc}
- __isset() : bool
- {@inheritdoc}
- __set() : void
- {@inheritdoc}
- __unset() : void
- {@inheritdoc}
- canBeDuplicated() : bool
- Determines if model can be duplicated
- canSaveVersions() : bool
- determines if varsion data should be saved on postPersist hook
- checkLoaded() : self
- ensures model is loaded
- compareWith() : array<string|int, mixed>
- current() : mixed
- {@inheritdoc}
- defaultTableName() : string
- gets model table name
- delete() : self
- removes model from db
- duplicate() : BaseModel
- Duplicate Model
- fill() : self
- fills empty model with data
- getChangedData() : array<string|int, mixed>|null
- gets model's changed data
- getClassName() : string
- getCollection() : BaseCollection
- returns a Model collection
- getCreatedAt() : DateTime
- getData() : mixed
- gets model's data
- getId() : int
- getIterator() : Traversable|ArrayIterator
- {@inheritdoc}
- getKeyField() : string|array<string|int, mixed>
- getKeyFieldValue() : mixed
- getNewObjectFromVersionData() : BaseModel|null
- getObject() : BaseModel|null
- getOwner() : User
- gets owner
- getPrimaryKey() : string
- getSearchCollection() : BaseCollection
- returns a Model collection using SearchManager for finding elements
- getTableColumns() : array<string|int, mixed>
- returns table columns
- getUpdatedAt() : DateTime
- getUserId() : int
- getVersionData() : string
- getVersions() : BaseCollection
- get the collection of version available for current model
- hasChanged() : bool
- hydrateStatementResult() : array<string|int, mixed>
- returns an array of models, starting from a statement Result
- isFirstSave() : bool
- is first save flag
- isLoaded() : bool
- checks if model is loaded
- isNew() : bool
- checks if model is new
- key() : mixed
- {@inheritdoc}
- load() : self
- loads model by id
- loadBy() : self
- loads model by field - value pair
- new() : static
- gets new empty model
- next() : mixed
- {@inheritdoc}
- offsetExists() : bool
- {@inheritdoc}
- offsetGet() : mixed
- {@inheritdoc}
- offsetSet() : void
- {@inheritdoc}
- offsetUnset() : void
- {@inheritdoc}
- persist() : self
- saves model on db
- postLoad() : self
- post load hook
- postPersist() : self
- post persist hook
- postRemove() : self
- post remove hook
- prePersist() : self
- pre persist hook
- preRemove() : self
- pre remove hook
- remove() : self
- removes model from db
- reset() : self
- resets model
- restoreVersion() : static
- Restore a previous version of the model
- rewind() : mixed
- {@inheritdoc}
- save() : self
- saves model on db
- saveVersion() : ModelVersion
- creates a version of current model
- select() : PDOStatement
- basic select statement
- serializeForVersioning() : array<string|int, mixed>
- setClassName() : self
- setCreatedAt() : self
- setData() : self
- sets model's data
- setId() : self
- setIsFirstSave() : $this
- sets is first save flag
- setPrimaryKey() : self
- setTableName() : self
- setUpdatedAt() : self
- setUserId() : self
- setVersionData() : self
- toJson() : string
- gets Model json rapresentation
- valid() : mixed
- {@inheritdoc}
- applyRestoredField() : void
- Apply a restored field to the current model
- emitEvent() : void
- Emits event to event manager
- getDbRow() : Row
- getModelBasicWhere() : Result
- gets basic where statement for model
- getModelName() : string
- gets object model name
- getOriginalData() : mixed
- gets model's original data
- getTableName() : string
- gets table name
- loadedObjectsIdentifier() : string
- setDbRow() : self
- setOriginalData() : $this
- sets model's original data
- arrayDiffRecursive() : array<string|int, mixed>
- checkDbName() : self
- checks if Row object is from correct table
Properties
$table_name
public
string|null
$table_name
= null
table name
$db_row
protected
Row
$db_row
= null
database row
$is_first_save
protected
bool
$is_first_save
first save flag
$keyField
protected
static string|array<string|int, mixed>
$keyField
= 'id'
$loadedObjects
protected
static array<string|int, mixed>
$loadedObjects
= []
objects cache
$original_data
private
array<string|int, mixed>|null
$original_data
= null
original model data
Methods
__call()
{@inheritdoc}
public
__call(string $name, mixed $arguments) : mixed
Parameters
- $name : string
- $arguments : mixed
Tags
__callStatic()
{@inheritdoc}
public
static __callStatic(string $name, mixed $arguments) : mixed
Parameters
- $name : string
- $arguments : mixed
Tags
__construct()
{@inheritdoc}
public
__construct([Row|null $db_row = null ]) : mixed
Parameters
- $db_row : Row|null = null
Tags
__get()
{@inheritdoc}
public
__get(mixed $key) : mixed
Parameters
- $key : mixed
__isset()
{@inheritdoc}
public
__isset(mixed $name) : bool
Parameters
- $name : mixed
Return values
bool__set()
{@inheritdoc}
public
__set(mixed $key, mixed $value) : void
Parameters
- $key : mixed
- $value : mixed
__unset()
{@inheritdoc}
public
__unset(mixed $name) : void
Parameters
- $name : mixed
canBeDuplicated()
Determines if model can be duplicated
public
static canBeDuplicated() : bool
Return values
boolcanSaveVersions()
determines if varsion data should be saved on postPersist hook
public
canSaveVersions() : bool
Return values
boolcheckLoaded()
ensures model is loaded
public
checkLoaded() : self
Tags
Return values
selfcompareWith()
public
compareWith(ModelVersion $other_version) : array<string|int, mixed>
Parameters
- $other_version : ModelVersion
Return values
array<string|int, mixed>current()
{@inheritdoc}
public
current() : mixed
defaultTableName()
gets model table name
public
static defaultTableName() : string
Return values
stringdelete()
removes model from db
public
delete() : self
Tags
Return values
selfduplicate()
Duplicate Model
public
duplicate() : BaseModel
Return values
BaseModelfill()
fills empty model with data
public
fill(int|Row $id) : self
Parameters
- $id : int|Row
Tags
Return values
selfgetChangedData()
gets model's changed data
public
getChangedData() : array<string|int, mixed>|null
Return values
array<string|int, mixed>|nullgetClassName()
public
getClassName() : string
Return values
stringgetCollection()
returns a Model collection
public
static getCollection() : BaseCollection
Return values
BaseCollectiongetCreatedAt()
public
getCreatedAt() : DateTime
Return values
DateTimegetData()
gets model's data
public
getData([mixed|null $column = null ]) : mixed
Parameters
- $column : mixed|null = null
getId()
public
getId() : int
Return values
intgetIterator()
{@inheritdoc}
public
getIterator() : Traversable|ArrayIterator
Return values
Traversable|ArrayIteratorgetKeyField()
public
static getKeyField() : string|array<string|int, mixed>
Return values
string|array<string|int, mixed>getKeyFieldValue()
public
getKeyFieldValue([bool $forceAsArray = false ]) : mixed
Parameters
- $forceAsArray : bool = false
getNewObjectFromVersionData()
public
getNewObjectFromVersionData() : BaseModel|null
Return values
BaseModel|nullgetObject()
public
getObject() : BaseModel|null
Return values
BaseModel|nullgetOwner()
gets owner
public
getOwner() : User
Tags
Attributes
Return values
UsergetPrimaryKey()
public
getPrimaryKey() : string
Return values
stringgetSearchCollection()
returns a Model collection using SearchManager for finding elements
public
static getSearchCollection([array<string|int, mixed> $conditions = [] ]) : BaseCollection
Parameters
- $conditions : array<string|int, mixed> = []
Return values
BaseCollectiongetTableColumns()
returns table columns
public
static getTableColumns() : array<string|int, mixed>
Return values
array<string|int, mixed>getUpdatedAt()
public
getUpdatedAt() : DateTime
Return values
DateTimegetUserId()
public
getUserId() : int
Return values
intgetVersionData()
public
getVersionData() : string
Return values
stringgetVersions()
get the collection of version available for current model
public
getVersions() : BaseCollection
Return values
BaseCollectionhasChanged()
public
hasChanged() : bool
Return values
boolhydrateStatementResult()
returns an array of models, starting from a statement Result
public
static hydrateStatementResult(Result $stmt) : array<string|int, mixed>
Parameters
- $stmt : Result
Tags
Return values
array<string|int, mixed>isFirstSave()
is first save flag
public
isFirstSave() : bool
Return values
boolisLoaded()
checks if model is loaded
public
isLoaded() : bool
Return values
boolisNew()
checks if model is new
public
isNew() : bool
Return values
boolkey()
{@inheritdoc}
public
key() : mixed
load()
loads model by id
public
static load(mixed $id[, bool $reset = false ]) : self
Parameters
- $id : mixed
- $reset : bool = false
Return values
selfloadBy()
loads model by field - value pair
public
static loadBy(string $field, mixed $value) : self
Parameters
- $field : string
- $value : mixed
Tags
Return values
selfnew()
gets new empty model
public
static new([array<string|int, mixed> $initial_data = [] ]) : static
Parameters
- $initial_data : array<string|int, mixed> = []
Tags
Return values
staticnext()
{@inheritdoc}
public
next() : mixed
offsetExists()
{@inheritdoc}
public
offsetExists(mixed $offset) : bool
Parameters
- $offset : mixed
Return values
booloffsetGet()
{@inheritdoc}
public
offsetGet(mixed $offset) : mixed
Parameters
- $offset : mixed
offsetSet()
{@inheritdoc}
public
offsetSet(mixed $offset, mixed $value) : void
Parameters
- $offset : mixed
- $value : mixed
offsetUnset()
{@inheritdoc}
public
offsetUnset(mixed $offset) : void
Parameters
- $offset : mixed
persist()
saves model on db
public
persist([array<string|int, mixed> $persistOptions = [] ]) : self
Parameters
- $persistOptions : array<string|int, mixed> = []
Tags
Return values
selfpostLoad()
post load hook
public
postLoad() : self
Return values
selfpostPersist()
post persist hook
public
postPersist([array<string|int, mixed> $persistOptions = [] ]) : self
Parameters
- $persistOptions : array<string|int, mixed> = []
Return values
selfpostRemove()
post remove hook
public
postRemove() : self
Return values
selfprePersist()
pre persist hook
public
prePersist([array<string|int, mixed> $persistOptions = [] ]) : self
Parameters
- $persistOptions : array<string|int, mixed> = []
Return values
selfpreRemove()
pre remove hook
public
preRemove() : self
Return values
selfremove()
removes model from db
public
remove() : self
Tags
Return values
selfreset()
resets model
public
reset() : self
Tags
Return values
selfrestoreVersion()
Restore a previous version of the model
public
restoreVersion(ModelVersion $version[, bool $deep = true ]) : static
Parameters
- $version : ModelVersion
- $deep : bool = true
Tags
Return values
staticrewind()
{@inheritdoc}
public
rewind() : mixed
save()
saves model on db
public
save([array<string|int, mixed> $persistOptions = [] ]) : self
Parameters
- $persistOptions : array<string|int, mixed> = []
Tags
Return values
selfsaveVersion()
creates a version of current model
public
saveVersion() : ModelVersion
Return values
ModelVersionselect()
basic select statement
public
static select([array<string|int, mixed> $options = [] ]) : PDOStatement
Parameters
- $options : array<string|int, mixed> = []
Return values
PDOStatementserializeForVersioning()
public
static serializeForVersioning(BaseModel $model[, array<string|int, mixed> &$visited = [] ][, int $depth = 0 ][, int $maxDepth = 1 ]) : array<string|int, mixed>
Parameters
- $model : BaseModel
- $visited : array<string|int, mixed> = []
- $depth : int = 0
- $maxDepth : int = 1
Return values
array<string|int, mixed>setClassName()
public
setClassName(string $class_name) : self
Parameters
- $class_name : string
Return values
selfsetCreatedAt()
public
setCreatedAt(DateTime $created_at) : self
Parameters
- $created_at : DateTime
Return values
selfsetData()
sets model's data
public
setData(array<string|int, mixed> $data) : self
Parameters
- $data : array<string|int, mixed>
Return values
selfsetId()
public
setId(int $id) : self
Parameters
- $id : int
Return values
selfsetIsFirstSave()
sets is first save flag
public
setIsFirstSave(bool $is_first_save) : $this
Parameters
- $is_first_save : bool
Return values
$thissetPrimaryKey()
public
setPrimaryKey(string $primary_key) : self
Parameters
- $primary_key : string
Return values
selfsetTableName()
public
setTableName(string $table_name) : self
Parameters
- $table_name : string
Return values
selfsetUpdatedAt()
public
setUpdatedAt(DateTime $updated_at) : self
Parameters
- $updated_at : DateTime
Return values
selfsetUserId()
public
setUserId(int $user_id) : self
Parameters
- $user_id : int
Return values
selfsetVersionData()
public
setVersionData(string $version_data) : self
Parameters
- $version_data : string
Return values
selftoJson()
gets Model json rapresentation
public
toJson([int $level = 0 ]) : string
Parameters
- $level : int = 0
-
internally used
Return values
stringvalid()
{@inheritdoc}
public
valid() : mixed
applyRestoredField()
Apply a restored field to the current model
protected
applyRestoredField(string $key, mixed $value) : void
Parameters
- $key : string
- $value : mixed
emitEvent()
Emits event to event manager
protected
emitEvent(mixed $eventName[, array<string|int, mixed> $additionalData = [] ]) : void
Parameters
- $eventName : mixed
- $additionalData : array<string|int, mixed> = []
getDbRow()
protected
getDbRow() : Row
Return values
Row —database row
getModelBasicWhere()
gets basic where statement for model
protected
static getModelBasicWhere([array<string|int, mixed>|null $condition = [] ][, array<string|int, mixed> $order = [] ]) : Result
Parameters
- $condition : array<string|int, mixed>|null = []
- $order : array<string|int, mixed> = []
Return values
ResultgetModelName()
gets object model name
protected
getModelName() : string
Return values
stringgetOriginalData()
gets model's original data
protected
getOriginalData([mixed|null $key = null ]) : mixed
Parameters
- $key : mixed|null = null
getTableName()
gets table name
protected
getTableName() : string
Return values
stringloadedObjectsIdentifier()
protected
static loadedObjectsIdentifier(mixed $id) : string
Parameters
- $id : mixed
Return values
stringsetDbRow()
protected
setDbRow(Row $db_row) : self
Parameters
- $db_row : Row
Return values
selfsetOriginalData()
sets model's original data
protected
setOriginalData(array<string|int, mixed>|null $original_data) : $this
Parameters
- $original_data : array<string|int, mixed>|null
Return values
$thisarrayDiffRecursive()
private
arrayDiffRecursive(array<string|int, mixed> $array1, array<string|int, mixed> $array2) : array<string|int, mixed>
Parameters
- $array1 : array<string|int, mixed>
- $array2 : array<string|int, mixed>
Return values
array<string|int, mixed>checkDbName()
checks if Row object is from correct table
private
checkDbName(Row $db_row) : self
Parameters
- $db_row : Row