You are here

public function ConfigManager::getHeadersToRemove in Remove HTTP headers 8

Gets the HTTP headers that should be removed.

Parameters

bool $skipCache: Flag whether or not the data should be retrieved directly from config.

Return value

string[] HTTP headers that should be removed. An empty array if the header data is not saved in the correct format.

1 call to ConfigManager::getHeadersToRemove()
ConfigManager::shouldHeaderBeRemoved in src/Config/ConfigManager.php
Whether or not the route with given name should be protected.

File

src/Config/ConfigManager.php, line 66

Class

ConfigManager
Manages module configuration.

Namespace

Drupal\remove_http_headers\Config

Code

public function getHeadersToRemove($skipCache = FALSE) : array {
  $headersToRemove = [];
  if ($skipCache === FALSE) {
    $cachedHeadersToRemoveData = $this
      ->getHeadersToRemoveFromCache();
    if (is_array($cachedHeadersToRemoveData)) {

      // Use the cached data.
      return $cachedHeadersToRemoveData;
    }
  }

  /* Load the headers that should be removed from config
     if they are not in the cache or the cache is not used. */
  $headersToRemoveData = $this
    ->getHeadersToRemoveFromConfig();

  // Only use the data if the format is correct.
  if (is_array($headersToRemoveData)) {
    $headersToRemove = $headersToRemoveData;

    /* Save the data to cache so it is cached for the next access. */
    $this
      ->saveHeadersToRemoveToCache($headersToRemove);
  }
  return $headersToRemove;
}