Represents a task's custom-field value.
- Immutable:
- When the entry belongs to a Change
- See also
- https://developers.asana.com/reference/custom-fields
|
readonly string string | $key |
| The <resource_subtype>_value(s) data key. More...
|
|
const | MAP |
|
readonly Api Api | $api |
|
array array self[] AbstractEntity[] | $data = [] |
|
array bool[] | $diff = [] |
|
const | MAP = [] |
|
|
$this | _set (string $field, $value) |
| Values are immutable when the entry belongs to a Change. More...
|
|
void | _setData (array $data) |
| Strips Asana's redundant CustomField and EnumOption data. More...
|
|
mixed | _get (string $field) |
| Magic method: getField() More...
|
|
bool | _has (string $field) |
| Magic method: hasField() More...
|
|
T | _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...
|
|
void | _setField (string $field, $value) |
| Sets a value, hydrating if mapped, and clears the diff. More...
|
|
◆ $key
readonly string string $key |
|
protected |
The <resource_subtype>_value(s)
data key.
◆ MAP
Initial value:= [
'date_value' => Date::class,
'enum_value' => EnumOption::class,
'multi_enum_values' => [EnumOption::class],
'people_value' => [User::class]
]
◆ __construct()
◆ __toString()
◆ _set()
$this _set |
( |
string |
$field, |
|
|
|
$value |
|
) |
| |
|
protected |
Values are immutable when the entry belongs to a Change.
- Parameters
-
- Returns
- $this
Reimplemented from Data.
◆ _setData()
void _setData |
( |
array |
$data | ) |
|
|
protected |
◆ getCustomField()
◆ getDateValue()
magic null Date getDateValue |
( |
| ) |
|
◆ getDisplayValue()
null string getDisplayValue |
( |
| ) |
|
Determines the human-readable value in a future-proof way.
If a new value is set, and the entry is for a mapped type, the updated display value is returned.
When the entry is for an unknown type, this attempts to determine it, but may fall back on the upstream display_value
, which won't be correct if the value was changed.
If you're getting incorrect display values for object-like entries, you should extend this class and add the new type/s to FieldEntry::MAP.
- Returns
- null|string
◆ getEnumValue()
For subtype enum
- Returns
- null|EnumOption
◆ getGid()
The custom field's GID.
- Returns
- string
◆ getMultiEnumValues()
For subtype multi_enum
- Returns
- EnumOption[]
◆ getNumberValue()
magic null number getNumberValue |
( |
| ) |
|
For subtype number
- Returns
- null|number
◆ getPeopleValue()
magic User [] getPeopleValue |
( |
| ) |
|
For subtype people
- Returns
- User[]
◆ getRawValue()
null number string array Data Data [] getRawValue |
( |
| ) |
|
|
final |
- Returns
- null|number|string|array|Data|Data[]
◆ getResourceSubtype()
magic string getResourceSubtype |
( |
| ) |
|
◆ getTextValue()
magic null string getTextValue |
( |
| ) |
|
For subtype text
- Returns
- null|string
◆ ofDate()
◆ ofEnum()
◆ ofMultiEnum()
magic bool ofMultiEnum |
( |
| ) |
|
◆ ofNumber()
◆ ofPeople()
◆ ofText()
◆ selectMultiEnumValues()
magic EnumOption [] selectMultiEnumValues |
( |
callable |
$filter | ) |
|
fn( EnumOption $option): bool
- Returns
- EnumOption[]
◆ selectPeopleValue()
magic User [] selectPeopleValue |
( |
callable |
$filter | ) |
|
◆ setDateValue()
$this setDateValue |
( |
|
$date | ) |
|
- Parameters
-
null | string | DateTimeInterface | Date | $date | |
- Returns
- $this
◆ setEnumValue()
$this setEnumValue |
( |
|
$value | ) |
|
- Parameters
-
null | string | EnumOption | $value | GID, name, or instance |
- Returns
- $this
◆ setMultiEnumValues()
$this setMultiEnumValues |
( |
array |
$values | ) |
|
- Parameters
-
array<string|EnumOption> | $values GIDs, names, or instances |
- Returns
- $this
◆ setNumberValue()
magic $this setNumberValue |
( |
?number |
$number | ) |
|
◆ setPeopleValue()
magic $this setPeopleValue |
( |
User[] |
$people | ) |
|
◆ setTextValue()
magic $this setTextValue |
( |
?string |
$text | ) |
|
◆ setValue()
Calls the respective setter depending on the entry's type.
Enum values can be set using EnumOption instances, names, or GIDs.
Dates can be set using Date instances, or date-like strings.
All other types must be set with their full representations.
Unmapped objects and object-lists can be given as associative arrays.
- Parameters
-
- Returns
- $this