You are here

public function StorageEntityApi::getDataToSave in Configuration Management 7.2

Saves the configuration object into the DataStore.

Overrides StoragePhp::getDataToSave

File

lib/Drupal/configuration/Storage/StorageEntityApi.php, line 25
Definition of Drupal\configuration\Storage\StorageEntityApi.

Class

StorageEntityApi

Namespace

Drupal\configuration\Storage

Code

public function getDataToSave() {
  $filename = $this->filename;
  $export = '$api = ' . $this
    ->export($this->api_version) . ";\n\n";
  $export .= '$data = entity_import(\'' . $this->entity_type . "', '" . addcslashes(entity_export($this->entity_type, $this->data, '  '), '\\\'') . "');\n\n";
  $export .= '$dependencies = ' . $this
    ->export($this->dependencies) . ";\n\n";
  $export .= '$optional = ' . $this
    ->export($this->optional_configurations) . ";\n\n";
  $export .= '$modules = ' . $this
    ->export($this->required_modules) . ";";
  $file_contents = "<?php\n/**\n * @file\n * {$filename}\n */\n\n" . $export . "\n";
  $this->hash = sha1($file_contents);
  return $file_contents;
}