You are here

public function BackgroundImageSettings::initWithData in Background Image 2.0.x

Same name and namespace in other branches
  1. 8 src/BackgroundImageSettings.php \Drupal\background_image\BackgroundImageSettings::initWithData()
  2. 2.x src/BackgroundImageSettings.php \Drupal\background_image\BackgroundImageSettings::initWithData()

Initializes a configuration object with pre-loaded data.

Parameters

array $data: Array of loaded data for this configuration object.

Return value

$this The configuration object.

Overrides StorableConfigBase::initWithData

File

src/BackgroundImageSettings.php, line 96

Class

BackgroundImageSettings

Namespace

Drupal\background_image

Code

public function initWithData(array $data) {
  $this->isNew = FALSE;

  // Set initial data to default settings for casting to work (needs keys).
  $this->data = $data;

  // Now cast initial data to ensure proper values.
  $this
    ->merge($data);

  // Indicate this is the original data.
  $this->originalData = $this->data;

  // Set initial overridden data to an empty array.
  $this->overriddenData = [];
  return $this;
}