You are here

public function GTMContainerManager::createAssets in GoogleTagManager 7.2

Prepares directory for and saves snippet files for a container.

Parameters

GTMContainer $container: The container configuration entity.

Return value

bool Whether the files were saved.

Overrides ContainerManagerInterface::createAssets

1 call to GTMContainerManager::createAssets()
GTMContainerManager::createAllAssets in includes/entity/manager.inc
Prepares directory for and saves snippet files for all containers.

File

includes/entity/manager.inc, line 31

Class

GTMContainerManager
Defines the Google tag container manager.

Code

public function createAssets($container) {
  $result = TRUE;
  $directory = $container
    ->snippetDirectory();
  if (!is_dir($directory) || !_google_tag_is_writable($directory) || !_google_tag_is_executable($directory)) {
    $result = _file_prepare_directory($directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
  }
  if ($result) {
    $result = $this
      ->saveSnippets($container);
  }
  else {
    $args = array(
      '%directory' => $directory,
    );
    $message = 'The directory %directory could not be prepared for use, possibly due to file system permissions. The directory either does not exist, or is not writable or searchable.';
    $this
      ->displayMessage($message, $args, 'error');
    watchdog('google_tag', $message, $args, WATCHDOG_ERROR);
  }
  return $result;
}