You are here

protected function CriticalCssProvider::getCurrentEntity in Critical CSS 8

Get current entity.

At this moment, it only works for nodes and taxonomy terms.

Return value

\Drupal\Core\Entity\ContentEntityInterface|null Matched file path, or null if nothing found.

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

File

src/Asset/CriticalCssProvider.php, line 319

Class

CriticalCssProvider
Critical CSS Provider.

Namespace

Drupal\critical_css\Asset

Code

protected function getCurrentEntity() {
  $entityBundles = [
    'node',
    'taxonomy_term',
  ];
  foreach ($entityBundles as $entityBundle) {
    $entity = $this->currentRouteMatch
      ->getParameter($entityBundle);
    if ($entity) {
      return $entity;
    }
  }
  return NULL;
}