Fr3nch13/CakePHP Utilities

NullContext
in package
implements ContextInterface

Provides a context provider that does nothing.

This context provider simply fulfils the interface requirements that FormHelper has.

Table of Contents

Interfaces

ContextInterface
Interface for FormHelper context implementations.

Methods

__construct()  : mixed
Constructor.
attributes()  : array<string|int, mixed>
Get an associative array of other attributes for a field name.
error()  : array<string|int, mixed>
Get the errors for a given field
fieldNames()  : array<string|int, string>
Get the field names of the top level object in this context.
getMaxLength()  : int|null
Get maximum length of a field from model validation.
getPrimaryKey()  : array<string|int, string>
Get the fields used in the context as a primary key.
getRequiredMessage()  : string|null
Gets the default "required" error message for a field
hasError()  : bool
Check whether a field has an error attached to it
isCreate()  : bool
Returns whether this form is for a create operation.
isPrimaryKey()  : bool
Returns true if the passed field name is part of the primary key for this context
isRequired()  : bool|null
Check if a given field is 'required'.
primaryKey()  : array<string|int, string>
Get the fields used in the context as a primary key.
type()  : string|null
Get the abstract field type for a given field name.
val()  : mixed
Get the current value for a given field.

Methods

__construct()

Constructor.

public __construct(array<string|int, mixed> $context) : mixed
Parameters
$context : array<string|int, mixed>

Context info.

attributes()

Get an associative array of other attributes for a field name.

public attributes(string $field) : array<string|int, mixed>
Parameters
$field : string

A dot separated path to get additional data on.

Tags
inheritDoc
Return values
array<string|int, mixed>

An array of data describing the additional attributes on a field.

error()

Get the errors for a given field

public error(string $field) : array<string|int, mixed>
Parameters
$field : string

A dot separated path to check errors on.

Tags
inheritDoc
Return values
array<string|int, mixed>

An array of errors, an empty array will be returned when the context has no errors.

fieldNames()

Get the field names of the top level object in this context.

public fieldNames() : array<string|int, string>
Tags
inheritDoc
Return values
array<string|int, string>

A list of the field names in the context.

getMaxLength()

Get maximum length of a field from model validation.

public getMaxLength(string $field) : int|null
Parameters
$field : string

Field name.

Tags
inheritDoc
Return values
int|null

getPrimaryKey()

Get the fields used in the context as a primary key.

public getPrimaryKey() : array<string|int, string>
Tags
inheritDoc
Return values
array<string|int, string>

getRequiredMessage()

Gets the default "required" error message for a field

public getRequiredMessage(string $field) : string|null
Parameters
$field : string

A dot separated path to the field name

Tags
inheritDoc
Return values
string|null

hasError()

Check whether a field has an error attached to it

public hasError(string $field) : bool
Parameters
$field : string

A dot separated path to check errors on.

Tags
inheritDoc
Return values
bool

Returns true if the errors for the field are not empty.

isCreate()

Returns whether this form is for a create operation.

public isCreate() : bool
Tags
inheritDoc
Return values
bool

isPrimaryKey()

Returns true if the passed field name is part of the primary key for this context

public isPrimaryKey(string $field) : bool
Parameters
$field : string

A dot separated path to the field a value is needed for.

Tags
inheritDoc
Return values
bool

isRequired()

Check if a given field is 'required'.

public isRequired(string $field) : bool|null
Parameters
$field : string

A dot separated path to check required-ness for.

Tags
inheritDoc
Return values
bool|null

primaryKey()

Get the fields used in the context as a primary key.

public primaryKey() : array<string|int, string>

Renamed to .

Return values
array<string|int, string>

type()

Get the abstract field type for a given field name.

public type(string $field) : string|null
Parameters
$field : string

A dot separated path to get a schema type for.

Tags
inheritDoc
Return values
string|null

An abstract data type or null.

val()

Get the current value for a given field.

public val(string $field[, array<string|int, mixed> $options = [] ]) : mixed
Parameters
$field : string

A dot separated path to the field a value

$options : array<string|int, mixed> = []

Options. is needed for.

Tags
inheritDoc

        
On this page

Search results