You are here

public function EntityConfigurationHandler::writeToDatabase in Configuration Management 7.3

Saves the given configuration into the database.

Parameters

\Configuration\Configuration $configuration: The configuration to be saved.

Overrides ConfigurationHandler::writeToDatabase

File

src/Handlers/EntityConfigurationHandler.php, line 55

Class

EntityConfigurationHandler

Namespace

Configuration\Handlers

Code

public function writeToDatabase(Configuration $configuration) {
  $name = $this
    ->getInternalId($configuration
    ->getIdentifier());
  $event = $this
    ->triggerEvent('write_to_database', $configuration);
  $entity = $event->configuration
    ->getData();
  if ($original = $this->configuration_manager
    ->drupal()
    ->entity_load_single($this
    ->getType(), $this
    ->getIdentifier())) {
    $entity->id = $original->id;
    unset($entity->is_new);
  }
  $this->configuration_manager
    ->drupal()
    ->entity_save($this
    ->getType(), $entity);
}