function ContentEntityBase::set

Same name and namespace in other branches
  1. 11.x core/lib/Drupal/Core/Entity/ContentEntityBase.php \Drupal\Core\Entity\ContentEntityBase::set()
  2. 10 core/lib/Drupal/Core/Entity/ContentEntityBase.php \Drupal\Core\Entity\ContentEntityBase::set()
  3. 8.9.x core/lib/Drupal/Core/Entity/ContentEntityBase.php \Drupal\Core\Entity\ContentEntityBase::set()
3 calls to ContentEntityBase::set()
User::addRole in core/modules/user/src/Entity/User.php
Add a role to a user.
User::removeRole in core/modules/user/src/Entity/User.php
Remove a role from a user.
User::setUsername in core/modules/user/src/Entity/User.php
Sets the username of this account.

File

core/lib/Drupal/Core/Entity/ContentEntityBase.php, line 624

Class

ContentEntityBase
Implements Entity Field API specific enhancements to the Entity class.

Namespace

Drupal\Core\Entity

Code

public function set($name, $value, $notify = TRUE) {
  // Assign the value on the child and overrule notify such that we get
  // notified to handle changes afterwards. We can ignore notify as there is
  // no parent to notify anyway.
  $this->get($name)
    ->setValue($value, TRUE);
  return $this;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.