You are here

public function ResourceFieldBase::addMetadata in RESTful 7.2

Add metadata to the field.

This is a general purpose metadata storage for the field to store other things that are not specifically the field value.

You can pass in a namespaced $key using a : as a delimiter. Namespaces will result in nested arrays. That means that addMetadata('foo:bar:baz', 'oof') will result in metadata['foo']['bar']['baz'] = 'oof'.

Parameters

string $key: The metadata item identifier.

mixed $value: The metadata value.

Overrides ResourceFieldInterface::addMetadata

File

src/Plugin/resource/Field/ResourceFieldBase.php, line 312
Contains \Drupal\restful\Plugin\resource\Field\ResourceFieldBase.

Class

ResourceFieldBase

Namespace

Drupal\restful\Plugin\resource\Field

Code

public function addMetadata($key, $value) {
  $path = explode(':', $key);
  $leave = array_pop($path);
  $element =& $this
    ->internalMetadataElement($key);
  $element[$leave] = $value;
}