You are here

public function ContainerManager::findAssets in GoogleTagManager 8

Finds snippet files for a container.

Parameters

Drupal\Core\Config\Entity\ConfigEntityInterface $container: The container configuration entity.

Return value

bool Whether the files were found.

Overrides ContainerManagerInterface::findAssets

1 call to ContainerManager::findAssets()
ContainerManager::getScriptAttachments in src/Entity/ContainerManager.php
Adds render array items of page attachments.

File

src/Entity/ContainerManager.php, line 292

Class

ContainerManager
Defines the Google tag container manager.

Namespace

Drupal\google_tag\Entity

Code

public function findAssets(ConfigEntityInterface $container) {
  $include_script_as_file = $this->config
    ->get('include_file');
  $include_classes = $container
    ->get('include_classes');
  $types = $include_classes ? [
    'data_layer',
    'script',
    'noscript',
  ] : [
    'script',
    'noscript',
  ];
  foreach ($types as $type) {
    if ($include_script_as_file && $type != 'noscript') {
      $uri = $container
        ->snippetURI($type);
      if (!is_file($uri)) {
        return FALSE;
      }
    }
    else {
      if (!($cache = $this->cache
        ->get($container
        ->snippetCid($type)))) {
        return FALSE;
      }
    }
  }
  return TRUE;
}