You are here

protected function AssetCollector::buildCssForEntity in Entity Print 8.2

Build the CSS for a single entity.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity to build the CSS for.

array $theme_info: A list of css libraries to add.

array $libraries: A list of CSS libraries.

1 call to AssetCollector::buildCssForEntity()
AssetCollector::getCssLibraries in src/Asset/AssetCollector.php
Inject the relevant css for the template.

File

src/Asset/AssetCollector.php, line 89

Class

AssetCollector
Collect the assets for the entities being printed.

Namespace

Drupal\entity_print\Asset

Code

protected function buildCssForEntity(EntityInterface $entity, array $theme_info, array &$libraries) {
  foreach ($theme_info as $key => $value) {

    // If the entity type doesn't match just skip.
    if ($key !== $entity
      ->getEntityTypeId()) {
      continue;
    }

    // Parse our css files per entity type and bundle.
    foreach ($value as $css_bundle => $css) {

      // If it's magic key "all" add it otherwise check the bundle.
      if ($css_bundle === 'all' || $entity
        ->bundle() === $css_bundle) {
        $libraries = array_merge($libraries, (array) $css);
      }
    }
  }
}