Problem/Motivation
Here's what Drupal\Core\Entity\ContentEntityBase::set()
looks like:
/**
* {@inheritdoc}
*/
public function set($name, $value, $notify = TRUE) {
// If default language or an entity key changes we need to react to that.
$notify = $name == 'langcode' || in_array($name, $this->getEntityType()->getKeys());
$this->get($name)->setValue($value, $notify);
}
Note the {@inheritdoc}
. That comes from Drupal\Core\Entity\FieldableEntityInterface
, which says this:
* @param string $field_name
* The name of the field to set; e.g., 'title' or 'name'.
* @param mixed $value
* The value to set, or NULL to unset the field.
* @param 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.
The relevant part being $nofity
, which is supposed to allow you to change the notification behavior.
I'm not entirely sure what the notification behavior is supposed to do; I can see wanting to put off a database flush until many fields are changed, so maybe that's what it's for. The documentation doesn't tell us...
The point is that if you look at the implementation above, you see that ContentEntityBase::set()
just obliterates $notify
without honoring it.
That wouldn't be such a big deal because, you know, maybe this implementation needs to deal with it differently, but ContentEntityBase
is the only class which implements FieldableEntityInterface
.
I'm left wondering what's up.
Proposed resolution
- Figure out whether to update the interface, or whether
ContentEntityBase::set()
is buggy.
- Fix whatever needs fixing.
- Write a test to prove that it's fixed.
Remaining tasks
User interface changes
API changes