\RedBeanPHP\UtilDiff

Diff Utility

The Look Utility class provides an easy way to generate tables and selects (pulldowns) from the database.

Summary

Methods
Properties
Constants
__construct()
diff()
No public properties found
No constants found
No protected methods found
$toolbox
N/A
No private methods found
No private properties found
N/A

Properties

$toolbox

$toolbox : \RedBeanPHP\Util\Toolbox

Type

\RedBeanPHP\Util\Toolbox

Methods

__construct()

__construct(\RedBeanPHP\ToolBox  $toolbox) 

Constructor.

The MatchUp class requires a toolbox

Parameters

\RedBeanPHP\ToolBox $toolbox

diff()

diff(\RedBeanPHP\OODBBean|array  $beans, \RedBeanPHP\OODBBean|array  $others, array  $filters = array('created', 'modified'), string  $format = '%s.%s.%s', string|NULL  $type = NULL) : array

Calculates a diff between two beans (or arrays of beans).

The result of this method is an array describing the differences of the second bean compared to the first, where the first bean is taken as reference. The array is keyed by type/property, id and property name, where type/property is either the type (in case of the root bean) or the property of the parent bean where the type resides. The diffs are mainly intended for logging, you cannot apply these diffs as patches to other beans. However this functionality might be added in the future.

The keys of the array can be formatted using the $format parameter. A key will be composed of a path (1st), id (2nd) and property (3rd). Using printf-style notation you can determine the exact format of the key. The default format will look like:

'book.1.title' => array( , )

If you only want a simple diff of one bean and you don't care about ids, you might pass a format like: '%1$s.%3$s' which gives:

'book.1.title' => array( , )

The filter parameter can be used to set filters, it should be an array of property names that have to be skipped. By default this array is filled with two strings: 'created' and 'modified'.

Parameters

\RedBeanPHP\OODBBean|array $beans

reference beans

\RedBeanPHP\OODBBean|array $others

beans to compare

array $filters

names of properties of all beans to skip

string $format

the format of the key, defaults to '%s.%s.%s'

string|NULL $type

type/property of bean to use for key generation

Returns

array