\Charcoal\ObjectObjectRevision

Represents the changeset of an object.

A revision is a record of modifications to an object.

Intended to be used to collect all routes related to models under a single source (e.g., database table).

\Charcoal\Object\Charcoal\Object\ObjectRoute for a similar model that aggregates data under a common source.

Summary

Methods
Properties
Constants
setDependencies()
setTargetType()
targetType()
setTargetId()
targetId()
setRevNum()
revNum()
setRevTs()
revTs()
setRevUser()
revUser()
setDataPrev()
dataPrev()
setDataObj()
dataObj()
setDataDiff()
dataDiff()
createFromObject()
createDiff()
recursiveDiff()
lastObjectRevision()
objectRevisionNum()
No public properties found
No constants found
setModelFactory()
modelFactory()
No protected properties found
N/A
No private methods found
$targetType
$targetId
$revNum
$revTs
$revUser
$dataPrev
$dataObj
$dataDiff
$modelFactory
N/A

Properties

$targetType

$targetType : string

Object type of this revision (required)

Type

string

$targetId

$targetId : mixed

Object ID of this revision (required)

Type

mixed

$revNum

$revNum : integer

Revision number. Sequential integer for each object's ID. (required)

Type

integer

$revTs

$revTs : \DateTimeInterface

Timestamp; when this revision was created

Type

\DateTimeInterface

$revUser

$revUser : string

The (admin) user that was

Type

string

$dataPrev

$dataPrev : array

Type

array

$dataObj

$dataObj : array

Type

array

$dataDiff

$dataDiff : array

Type

array

$modelFactory

$modelFactory : \Charcoal\Factory\FactoryInterface

Type

\Charcoal\Factory\FactoryInterface

Methods

setDependencies()

setDependencies(\Pimple\Container  $container) : void

Dependencies

Parameters

\Pimple\Container $container

DI Container.

setTargetType()

setTargetType(string  $targetType) : \Charcoal\Object\ObjectRevision

Parameters

string $targetType

The object type (type-ident).

Throws

\InvalidArgumentException

If the obj type parameter is not a string.

Returns

\Charcoal\Object\ObjectRevision

Chainable

targetType()

targetType() : string

Returns

string

setTargetId()

setTargetId(mixed  $targetId) : \Charcoal\Object\ObjectRevision

Parameters

mixed $targetId

The object ID.

Returns

\Charcoal\Object\ObjectRevision

Chainable

targetId()

targetId() : mixed

Returns

mixed

setRevNum()

setRevNum(integer  $revNum) : \Charcoal\Object\ObjectRevision

Parameters

integer $revNum

The revision number.

Throws

\InvalidArgumentException

If the revision number argument is not numerical.

Returns

\Charcoal\Object\ObjectRevision

Chainable

revNum()

revNum() : integer

Returns

integer

setRevTs()

setRevTs(mixed  $revTs) : \Charcoal\Object\ObjectRevision

Parameters

mixed $revTs

The revision's timestamp.

Throws

\InvalidArgumentException

If the timestamp is invalid.

Returns

\Charcoal\Object\ObjectRevision

Chainable

revTs()

revTs() : \DateTimeInterface|null

Returns

\DateTimeInterface|null

setRevUser()

setRevUser(string  $revUser) : \Charcoal\Object\ObjectRevision

Parameters

string $revUser

The revision user ident.

Throws

\InvalidArgumentException

If the revision user parameter is not a string.

Returns

\Charcoal\Object\ObjectRevision

Chainable

revUser()

revUser() : string

Returns

string

setDataPrev()

setDataPrev(string|array  $data) : \Charcoal\Object\ObjectRevision

Parameters

string|array $data

The previous revision data.

Returns

\Charcoal\Object\ObjectRevision

Chainable

dataPrev()

dataPrev() : array

Returns

array

setDataObj()

setDataObj(array|string  $data) : \Charcoal\Object\ObjectRevision

Parameters

array|string $data

The current revision (object) data.

Returns

\Charcoal\Object\ObjectRevision

Chainable

dataObj()

dataObj() : array

Returns

array

setDataDiff()

setDataDiff(array|string  $data) : \Charcoal\Object\ObjectRevision

Parameters

array|string $data

The data diff.

Returns

\Charcoal\Object\ObjectRevision

dataDiff()

dataDiff() : array

Returns

array

createFromObject()

createFromObject(\Charcoal\Object\RevisionableInterface  $obj) : \Charcoal\Object\ObjectRevision

Create a new revision from an object

  1. Load the last revision
  2. Load the current item from DB
  3. Create diff from (1) and (2).

Parameters

\Charcoal\Object\RevisionableInterface $obj

The object to create the revision from.

Returns

\Charcoal\Object\ObjectRevision

Chainable

createDiff()

createDiff(array  $dataPrev = null, array  $dataObj = null) : array

Parameters

array $dataPrev

Optional. Previous revision data.

array $dataObj

Optional. Current revision (object) data.

Returns

array —

The diff data

recursiveDiff()

recursiveDiff(array  $array1, array  $array2) : array

Recursive arrayDiff.

Parameters

array $array1

First array.

array $array2

Second Array.

Returns

array —

The array diff.

objectRevisionNum()

objectRevisionNum(\Charcoal\Object\RevisionableInterface  $obj, integer  $revNum) : \Charcoal\Object\ObjectRevision

Retrieve a specific object revision, by revision number.

Parameters

\Charcoal\Object\RevisionableInterface $obj

Target object.

integer $revNum

The revision number to load.

Returns

\Charcoal\Object\ObjectRevision

setModelFactory()

setModelFactory(\Charcoal\Factory\FactoryInterface  $factory) : void

Parameters

\Charcoal\Factory\FactoryInterface $factory

The factory used to create models.

modelFactory()

modelFactory() : \Charcoal\Factory\FactoryInterface

Returns

\Charcoal\Factory\FactoryInterface —

The model factory.