WireData::data() method

Get or set a low-level data value

Like get() or set() but will only get/set from the WireData's protected $data array. This is used to bypass any extra logic a class may have added to its get() or set() methods. The benefit of this method over get() is that it excludes API vars and potentially other things (defined by descending classes) that you may not want.

  • To get a value, simply omit the $value argument.
  • To set a value, specify both the $key and $value arguments.
  • If you omit a $key and $value, this method will return the entire data array.

Example

// Set a property
$item->data('some_property', 'some value');

// Get the value of a previously set property
$value = $item->data('some_property'); 

Usage

// basic usage
$array = $wireData->data();

// usage with all arguments
$array = $wireData->data($key = null, mixed $value = null);

Arguments

NameType(s)Description
key (optional)string, array

Property you want to get or set, or associative array of properties you want to set.

value (optional)mixed

Optionally specify a value if you want to set rather than get. Or Specify boolean TRUE if setting an array via $key and you want to overwrite any existing values (rather than merge).

Return value

array WireData null

Returns one of the following:

  • mixed - Actual value if getting a previously set value.
  • null - If you are attempting to get a value that has not been set.
  • $this - If you are setting a value.

WireData methods and properties

API reference based on ProcessWire core version 3.0.236

Latest news

  • ProcessWire Weekly #523
    In the 523rd issue of ProcessWire Weekly we'll check out what's new in the core this week, share some new module related news, and more. Read on!
    Weekly.pw / 18 May 2024
  • ProFields Table Field with Actions support
    This week we have some updates for the ProFields table field (FieldtypeTable). These updates are primarily focused on adding new tools for the editor to facilitate input and management of content in a table field.
    Blog / 12 April 2024
  • Subscribe to weekly ProcessWire news

“Indeed, if ProcessWire can be considered as a CMS in its own right, it also offers all the advantages of a CMF (Content Management Framework). Unlike other solutions, the programmer is not forced to follow the proposed model and can integrate his/her ways of doing things.” —Guy Verville, Spiria Digital Inc.