You are here

protected function ResourceFieldBase::internalMetadataElement in RESTful 7.2

Returns the last array element from the nested namespace array.

Searches in the metadata nested array the element in the data tree pointed by the colon separated key. If the key goes through a non-existing path, it initalize an empty array. The reference to that element is returned for reading and writing purposes.

Parameters

string $key: The namespaced key.

Return value

array The reference to the array element.

2 calls to ResourceFieldBase::internalMetadataElement()
ResourceFieldBase::addMetadata in src/Plugin/resource/Field/ResourceFieldBase.php
Add metadata to the field.
ResourceFieldBase::getMetadata in src/Plugin/resource/Field/ResourceFieldBase.php
Add metadata to the field.

File

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

Class

ResourceFieldBase

Namespace

Drupal\restful\Plugin\resource\Field

Code

protected function &internalMetadataElement($key) {

  // If there is a namespace, then use it to do nested arrays.
  $path = explode(':', $key);
  array_pop($path);
  $element =& $this->metadata;
  foreach ($path as $path_item) {
    if (!isset($element[$path_item])) {

      // Initialize an empty namespace.
      $element[$path_item] = array();
    }
    $element = $element[$path_item];
  }
  return $element;
}