\Hazaar\Model
Strict
Abstract
Summary
Methods Properties Constants
ake
get
has
key
set
No constants
Properties
$allow_undefined
$allow_undefined
Undefined values will be automatically added and their type will be detected.
$convert_nulls
$convert_nulls
Automatically convert null values to empty strings if the field is of type string.
$current
$current
The current value for array access returned by each().
$disable_callbacks
$disable_callbacks
Disable all callbacks while this is true.
$fields
$fields
The field definition.
$ignore_undefined
$ignore_undefined
Undefined values will be ignored. This is checked first.
$loaded
$loaded
Internal loaded flag. This allows read only fields to be set during startup.
$values
$values
The current values of all defined fields.
Methods
__call()
__call($func, $argv) : mixed
Magic method for calling array_* functions on the \Hazaar\Model\Strict class.

Tags

Throws

Exception\BadMethodCall

Parameters

$funcmixed

No description

$argvmixed

No description

Returns

mixed
__construct()
__construct()
Strict model constructor

The constructor has optional parameters that can vary depending on the implementation. The first parameter is an array containing the initial data to be loaded into the model. Any subsequent arguments are passed directly and “as is” to the Hazaar\Model\Strict::construct() method implemented by the extending class.

Tags

Throws

Exception\InitMissing

Throws

Exception\BadFieldDefinition

__destruct()
__destruct()
Strict model destructor

The destructor calls the shutdown method to allow the extending class to do any cleanup functions.

__get()
__get($key)

Parameters

$key

No description

__set()
__set($key, $value)

Parameters

$key

No description

$value

No description

ake()
ake($key, $default = null, $non_empty = false)

Parameters

$key

No description

$default

No description

$non_empty

No description

append()
append($key, $item) : mixed
Append an element to an array item

Parameters

$keymixed

The name of the array field to append to.

$itemmixed

The item to append on to the end of the array.

Returns

mixed

The item that was just appended.

array_walk()
array_walk($callback, $userdata = null)
Apply a user supplied function to every member of an array

Applies the user-defined callback function to each element of the array array.

ChildArray::walk() is not affected by the internal array pointer of array. ChildArray::walk() will walk through the entire array regardless of pointer position.

For more information on this method see PHP’s array_walk() function.

Parameters

$callbackmixed

Typically, callback takes on two parameters. The array parameter’s value being the first, and the key/index second.

$userdatamixed

If the optional userdata parameter is supplied, it will be passed as the third parameter to the callback.

array_walk_recursive()
array_walk_recursive($callback, $userdata = null)
Apply a user supplied function to every member of an array

Applies the user-defined callback function to each element of the array array.

ChildArray::walk() is not affected by the internal array pointer of array. ChildArray::walk() will walk through the entire array regardless of pointer position.

For more information on this method see PHP’s array_walk() function.

Parameters

$callbackmixed

Typically, callback takes on two parameters. The array parameter’s value being the first, and the key/index second.

$userdatamixed

If the optional userdata parameter is supplied, it will be passed as the third parameter to the callback.

count()
count() : int
Returns the number of fields stored in the model.

Tags

Since

1.3.0

Returns

int
current()
current()

Return the current element in the model

Tags

Since

1.0.0

execCallback()
execCallback($cb_def, $value, $key) : mixed

Execute the a callback function on a key/value pair.

Parameters

$cb_defMixed

The callback definition

$valuemixed

The current value of the element.

$keystring

The key name of the element.

Returns

mixed
exportHMV()
exportHMV($ignore_empty = false, $export_all = false, $obj = null) : array
Export the mdel in HazaarModelView format for easy display in views.

Tags

Since

2.0.0

Parameters

$ignore_empty

No description

$export_all

No description

$obj

No description

Returns

array

The array of values stored in the model in key => (label, value) tuples. Returns null if model is empty.

exportHMVArray()
exportHMVArray($array, $def, $hide_empty = false, $export_all = false, $object = null) : array
Exports and array in HazaarModelView format using the supplied definition

Tags

Since

2.0.0

Parameters

$arraymixed

The array to convert and export.

$defmixed

The strict model definition.

$hide_empty

No description

$export_all

No description

$object

No description

Returns

array

The array of values in key => (label, value) tuples. Returns null if first parameter is not an array.

extend()
extend($values, $exec_filters = true, $ignore_keys = null)

Parameters

$values

No description

$exec_filters

No description

$ignore_keys

No description

find()
find($field, $criteria = Array ( ) , $multiple = false)

Parameters

$field

No description

$criteria

No description

$multiple

No description

get()
get($key, $exec_filters = true)

Parameters

$key

No description

$exec_filters

No description

getDefinition()
getDefinition($key) : array
Return the field definition for the requested field.

Parameters

$keymixed

The key of the field to return the definition for.

Returns

array
getType()
getType($key)

Parameters

$key

No description

has()
has($key) : boolean
Return true/false indicating if a field has been defined.

If the field is not “defined” but instead $allow_undefined has been enabled and the field was added, this will also return true.

Parameters

$keymixed

The field name to check.

Returns

boolean
hasValues()
hasValues() : boolean
Test if any fields have non-null values

Returns

boolean
isObject()
isObject($key)

Parameters

$key

No description

jsonSerialize()
jsonSerialize()
key()
key()

Return the current key from the model

Tags

Since

1.0.0

loadDefinition()
loadDefinition($field_definition)
Loads the provided field definition into the model.

Parameters

$field_definitionarray

No description

next()
next()

Move to the next element in the model

Tags

Since

1.0.0

offsetExists()
offsetExists($offset)
Array Access Methods

Parameters

$offset

No description

offsetGet()
offsetGet($offset)

Parameters

$offset

No description

offsetSet()
offsetSet($offset, $value)

Parameters

$offset

No description

$value

No description

offsetUnset()
offsetUnset($offset)

Parameters

$offset

No description

populate()
populate($data, $exec_filters = false) : boolean
Populate the model with data contained in the supplied array.

Parameters

$datamixed

The array of data.

$exec_filtersmixed

Execute any callback filters. For populate this is disabled by default.

Returns

boolean
prepare()
prepare($data)

Parameters

$data

No description

push()
push($key, $item) : mixed
Alias for Hazaar\Model\Strict::append()

Added to help remove some confusion as to appends purpose.

Parameters

$keystring

The name of the array field to push to.

$itemmixed

The item to push on to the end of the array.

Returns

mixed

The item that was just pushed.

resolveArray()
resolveArray($array, $disable_callbacks = false, $depth = null, $show_hidden = false)

Parameters

$array

No description

$disable_callbacks

No description

$depth

No description

$show_hidden

No description

rewind()
rewind()

Set the internal pointer the first element

Tags

Since

1.0.0

set()
set($key, $value, $exec_filters = true)

Parameters

$key

No description

$value

No description

$exec_filters

No description

toArray()
toArray($disable_callbacks = false, $depth = null, $show_hidden = true)
Convert data into an array

If field values are Strict models, then convert them to arrays as well.

Tags

Since

1.0.0

Parameters

$disable_callbacks

No description

$depth

No description

$show_hidden

No description

valid()
valid()

Test that an element exists at the current internal pointer position

Tags

Since

1.0.0