public function ContainerManager::deleteAssets in GoogleTagManager 8
Deletes snippet files for a container.
Parameters
Drupal\Core\Config\Entity\ConfigEntityInterface $container: The container configuration entity.
Return value
bool Whether the files were deleted.
Overrides ContainerManagerInterface::deleteAssets
1 call to ContainerManager::deleteAssets()
- ContainerManager::deleteAllAssets in src/
Entity/ ContainerManager.php - Deletes snippet files for all containers.
File
- src/
Entity/ ContainerManager.php, line 263
Class
- ContainerManager
- Defines the Google tag container manager.
Namespace
Drupal\google_tag\EntityCode
public function deleteAssets(ConfigEntityInterface $container) {
$include_classes = $container
->get('include_classes');
$types = $include_classes ? [
'data_layer',
'script',
'noscript',
] : [
'script',
'noscript',
];
$directory = $container
->snippetDirectory();
$result = TRUE;
if (!empty($directory) && is_dir($directory)) {
$result = $this->fileSystem
->deleteRecursive($directory);
}
$args = [
'@count' => count($types),
'%container' => $container
->get('label'),
];
if (!$result) {
$message = 'An error occurred deleting @count snippet files for %container container. Contact the site administrator if this persists.';
$this
->displayMessage($message, $args, MessengerInterface::TYPE_ERROR);
$this->logger
->error($message, $args);
}
else {
$message = 'Deleted @count snippet files for %container container.';
$this
->displayMessage($message, $args);
// In case this is not called during core cache rebuild, then [OMIT?]
// Reset the URL query argument so browsers reload snippet files.
// @todo Do these snippet files have the js token in a query argument? Yes. [OMIT]
_drupal_flush_css_js();
}
return $result;
}