You are here

public function ConfigEntityRevisionsConfigEntityTrait::set in Config Entity Revisions 8.2

1 call to ConfigEntityRevisionsConfigEntityTrait::set()
ConfigEntityRevisionsConfigEntityTrait::setNewRevision in src/ConfigEntityRevisionsConfigEntityTrait.php
Enforces an entity to be saved as a new revision.

File

src/ConfigEntityRevisionsConfigEntityTrait.php, line 442

Class

ConfigEntityRevisionsConfigEntityTrait
Trait ConfigEntityRevisionsConfigEntityTrait.

Namespace

Drupal\config_entity_revisions

Code

public function set($property_name, $value) {
  if ($this instanceof EntityWithPluginCollectionInterface) {
    $plugin_collections = $this
      ->getPluginCollections();
    if (isset($plugin_collections[$property_name])) {

      // If external code updates the settings, pass it along to the plugin.
      $plugin_collections[$property_name]
        ->setConfiguration($value);
    }
  }

  // Special handling for the moderation state.
  if (isset($this->{$property_name}) && $this->{$property_name} instanceof ModerationStateFieldItemList) {
    $this->moderation_state
      ->setValue($value);
    $this
      ->getContentEntity()->moderation_state
      ->setValue($value);
  }
  else {
    $this->{$property_name} = $value;
  }
  return $this;
}