You are here

public function GTMContainerManager::createAllAssets in GoogleTagManager 7.2

Prepares directory for and saves snippet files for all containers.

Return value

bool Whether the files were saved.

Overrides ContainerManagerInterface::createAllAssets

File

includes/entity/manager.inc, line 185

Class

GTMContainerManager
Defines the Google tag container manager.

Code

public function createAllAssets() {
  $containers = $this
    ->loadContainers();
  if (!$containers) {
    return;
  }
  if (\GTMSettings::getInstance()
    ->get('flush_snippets')) {
    $directory = \GTMSettings::getInstance()
      ->get('uri');
    if (!empty($directory)) {

      // Remove any stale files (e.g. module update or machine name change).
      file_unmanaged_delete_recursive($directory . '/google_tag');
    }
  }

  // Create snippet files for enabled containers.
  // $containers = $this->loadContainers();
  $result = TRUE;
  foreach ($containers as $container) {
    $result = !$this
      ->createAssets($container) ? FALSE : $result;
  }
  return $result;
}