public function ContainerManager::createAssets in GoogleTagManager 8
Prepares directory for and saves snippet files for a container.
@todo Which class-interface to use on @param?
Parameters
Drupal\Core\Config\Entity\ConfigEntityInterface $container: The container configuration entity.
Return value
bool Whether the files were saved.
Overrides ContainerManagerInterface::createAssets
2 calls to ContainerManager::createAssets()
- ContainerManager::createAllAssets in src/
Entity/ ContainerManager.php - Prepares directory for and saves snippet files for all containers.
- ContainerManager::getScriptAttachments in src/
Entity/ ContainerManager.php - Adds render array items of page attachments.
File
- src/
Entity/ ContainerManager.php, line 79
Class
- ContainerManager
- Defines the Google tag container manager.
Namespace
Drupal\google_tag\EntityCode
public function createAssets(ConfigEntityInterface $container) {
$include_script_as_file = $this->config
->get('include_file');
if (!$include_script_as_file) {
return $this
->saveSnippets($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, FileSystemInterface::CREATE_DIRECTORY | FileSystemInterface::MODIFY_PERMISSIONS);
}
if ($result) {
$result = $this
->saveSnippets($container);
}
else {
$args = [
'%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, MessengerInterface::TYPE_ERROR);
$this->logger
->error($message, $args);
}
return $result;
}