You are here

public function Profile::unsetData in Profile 8

Unsets a profile data value with the given key.

Parameters

string $key: The key.

Return value

$this

Overrides ProfileInterface::unsetData

File

src/Entity/Profile.php, line 161

Class

Profile
Defines the profile entity class.

Namespace

Drupal\profile\Entity

Code

public function unsetData($key) {
  if (!$this
    ->get('data')
    ->isEmpty()) {
    $data = $this
      ->get('data')
      ->first()
      ->getValue();
    unset($data[$key]);
    $this
      ->set('data', $data);
  }
  return $this;
}