public function ContentEntityBase::set in Zircon Profile 8.0
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/Entity/ContentEntityBase.php \Drupal\Core\Entity\ContentEntityBase::set()
Sets a field value.
Parameters
string $field_name: The name of the field to set; e.g., 'title' or 'name'.
mixed $value: The value to set, or NULL to unset the field.
bool $notify: (optional) Whether to notify the entity of the change. Defaults to TRUE. If the update stems from the entity, set it to FALSE to avoid being notified again.
Return value
$this
Throws
\InvalidArgumentException If the specified field does not exist.
Overrides FieldableEntityInterface::set
60 calls to ContentEntityBase::set()
- BlockContent::setInfo in core/
modules/ block_content/ src/ Entity/ BlockContent.php - Sets the block description.
- BlockContent::setRevisionLog in core/
modules/ block_content/ src/ Entity/ BlockContent.php - Sets the block revision log message.
- Comment::setAuthorName in core/
modules/ comment/ src/ Entity/ Comment.php - Sets the name of the author of the comment.
- Comment::setCreatedTime in core/
modules/ comment/ src/ Entity/ Comment.php - Sets the creation date of the comment.
- Comment::setFieldName in core/
modules/ comment/ src/ Entity/ Comment.php - Sets the field ID for which this comment is attached.
File
- core/
lib/ Drupal/ Core/ Entity/ ContentEntityBase.php, line 511 - Contains \Drupal\Core\Entity\ContentEntityBase.
Class
- ContentEntityBase
- Implements Entity Field API specific enhancements to the Entity class.
Namespace
Drupal\Core\EntityCode
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;
}