You are here

protected function CriticalCssProvider::getFilePathByKey in Critical CSS 8

Get critical CSS file path by a key (id, string, etc).

Parameters

string $key: Key to search.

Return value

string Critical CSS string.

1 call to CriticalCssProvider::getFilePathByKey()
CriticalCssProvider::calculateFilePaths in src/Asset/CriticalCssProvider.php
Get all possible paths to search, relatives to theme.

File

src/Asset/CriticalCssProvider.php, line 223

Class

CriticalCssProvider
Critical CSS Provider.

Namespace

Drupal\critical_css\Asset

Code

protected function getFilePathByKey($key) {
  if (empty($key)) {
    return NULL;
  }
  $criticalCssDirPath = str_replace('..', '', $this->config
    ->get('dir_path'));
  $themePath = $this->themeManager
    ->getActiveTheme()
    ->getPath();
  $criticalCssDir = $themePath . $criticalCssDirPath;
  return $criticalCssDir . '/' . $key . '.css';
}