You are here

public function BackgroundImage::getSettingsHash in Background Image 8

Same name and namespace in other branches
  1. 2.x src/Entity/BackgroundImage.php \Drupal\background_image\Entity\BackgroundImage::getSettingsHash()
  2. 2.0.x src/Entity/BackgroundImage.php \Drupal\background_image\Entity\BackgroundImage::getSettingsHash()

Retrieves the settings hash.

Parameters

string $name: A setting name to retrieve.

Return value

string

Overrides BackgroundImageInterface::getSettingsHash

File

src/Entity/BackgroundImage.php, line 440

Class

BackgroundImage
Defines the Background Image entity.

Namespace

Drupal\background_image\Entity

Code

public function getSettingsHash($name = NULL) {
  if (!isset($this->settingsHash)) {
    $data = [];
    if (isset($name)) {
      $data[$name] = $this
        ->getSetting($name);
    }
    else {
      $data['settings'] = $this
        ->getSettings()
        ->get();
    }

    // Add entity specific target.
    if ((!isset($name) || $name === 'text' || $name === 'text.value') && $this
      ->hasEntityToken() && ($entity = $this
      ->getBackgroundImageManager()
      ->getEntityFromCurrentRoute())) {
      $data['entity'] = $entity;
    }
    $serialized = serialize($data);
    $this->settingsHash = Crypt::hashBase64($serialized);
  }
  return $this->settingsHash;
}