You are here

public function Profile::getData in Profile 8

Gets a profile data value with the given key.

Used to store arbitrary data for the profile.

Parameters

string $key: The key.

mixed $default: The default value.

Return value

mixed The value.

Overrides ProfileInterface::getData

File

src/Entity/Profile.php, line 142

Class

Profile
Defines the profile entity class.

Namespace

Drupal\profile\Entity

Code

public function getData($key, $default = NULL) {
  $data = [];
  if (!$this
    ->get('data')
    ->isEmpty()) {
    $data = $this
      ->get('data')
      ->first()
      ->getValue();
  }
  return isset($data[$key]) ? $data[$key] : $default;
}