FieldEntries
+ Inheritance diagram for FieldEntries:

Description

Acts as a container for a task's custom-field values.

Field array-access is by GID (recommended) or name.

Protected Properties

array FieldEntry[] $data = []
 Field entries, keyed by GID. More...
 
array string[] $gids = []
 GIDs, keyed by field entry name. More...
 
array string[] $names = []
 Field entry names, keyed by GID. More...
 
array string[] $types = []
 [ entry gid => type ] More...
 
- Protected Properties inherited from Data
readonly Api Api $api
 
array array self[] AbstractEntity[] $data = []
 
array bool[] $diff = []
 
const MAP = []
 

Public Methods

 __construct (Task $task, array $data=[])
 
int count ()
 
FieldEntry[] getEntries ()
 
null FieldEntry getEntry (string $ident)
 
Generator< string, null|string > getIterator ()
 Human values, keyed by entry GID. More...
 
Task getTask ()
 
array< string, null|number|string > getValues ()
 
null string offsetGet ($entryIdent)
 An entry's display-value. More...
 
void offsetSet ($entryIdent, $value)
 Sets an entry's value. More...
 
magic FieldEntry[] selectEntries (callable $filter)
 fn( FieldEntry $entry ): bool More...
 
array toArray (bool $diff=false)
 Overridden to prepare entry diffs for task upsert. More...
 
- Public Methods inherited from Data
mixed __call (string $method, array $args)
 Magic method handler. More...
 
 __construct (Api|self $caller, array $data=[])
 
array __serialize ()
 
void __unserialize (array $data)
 
bool isDiff ()
 Whether the instance has changes. More...
 
array jsonSerialize ()
 
bool offsetExists (mixed $offset)
 
mixed offsetGet (mixed $offset)
 
void offsetSet (mixed $offset, mixed $value)
 
void offsetUnset (mixed $offset)
 

Protected Methods

void _setField (string $i, $data)
 Overridden to use $data for each FieldEntry. More...
 
- Protected Methods inherited from Data
mixed _get (string $field)
 Magic method: getField() More...
 
bool _has (string $field)
 Magic method: hasField() More...
 
_hydrate (string $class, $item)
 Sub-data factory that draws from the entity pool. More...
 
bool _is (string $field)
 Magic method: isField() More...
 
bool _of (string $resourceSubtype)
 Magic method: ofResourceSubtypeValue() More...
 
array _select (string|iterable $subject, callable $filter,... $args)
 Magic method: selectField(callable $filter) More...
 
$this _set (string $field, $value)
 Magic method: setField(mixed $value) More...
 
void _setData (array $data)
 Clears all diffs and sets all data, hydrating mapped fields. More...
 

Properties

◆ $data

array FieldEntry [] $data = []
protected

Field entries, keyed by GID.

◆ $gids

array string [] $gids = []
protected

GIDs, keyed by field entry name.

◆ $names

array string [] $names = []
protected

Field entry names, keyed by GID.

◆ $types

array string [] $types = []
protected

[ entry gid => type ]

Constructor

◆ __construct()

__construct ( Task  $task,
array  $data = [] 
)
Parameters
Task$task
array$dataEnumerated FieldEntry data.

Methods

◆ _setField()

void _setField ( string  $i,
  $data 
)
protected

Overridden to use $data for each FieldEntry.

Parameters
string$iField entry enumeration. This is ignored, since entries are keyed by GID.
array$data
Returns
void

Reimplemented from Data.

◆ count()

int count ( )
final
Returns
int

◆ getEntries()

FieldEntry [] getEntries ( )
Returns
FieldEntry[]

◆ getEntry()

null FieldEntry getEntry ( string  $ident)
Parameters
string$identGID or name
Returns
null|FieldEntry

◆ getIterator()

Generator<string,null|string> getIterator ( )

Human values, keyed by entry GID.

Returns
Generator<string,null|string>

◆ getTask()

Task getTask ( )
Returns
Task

◆ getValues()

array<string,null|number|string> getValues ( )
final
Returns
array<string,null|number|string>

◆ offsetGet()

null string offsetGet (   $entryIdent)
final

An entry's display-value.

Parameters
string$entryIdentGID or name
Returns
null|string Also returns null if there is no such entry.

◆ offsetSet()

void offsetSet (   $entryIdent,
  $value 
)
final

Sets an entry's value.

The entry must exist.

{

See also
FieldEntry::setValue()}
Parameters
string$entryIdentGID or name
mixed$value
Returns
void

◆ selectEntries()

magic FieldEntry [] selectEntries ( callable  $filter)

fn( FieldEntry $entry ): bool

Returns
FieldEntry[]

◆ toArray()

array toArray ( bool  $diff = false)

Overridden to prepare entry diffs for task upsert.

Parameters
bool$diff
Returns
array

Reimplemented from Data.