public function SnippetBuilder::createAssets in Hotjar 8
Same name and namespace in other branches
- 8.2 src/SnippetBuilder.php \Drupal\hotjar\SnippetBuilder::createAssets()
Prepares directory for and saves snippet files based on current settings.
Return value
bool Whether the files were saved.
Overrides SnippetBuilderInterface::createAssets
File
- src/
SnippetBuilder.php, line 133
Class
- SnippetBuilder
- Class SnippetBuilder.
Namespace
Drupal\hotjarCode
public function createAssets() {
$result = TRUE;
$directory = 'public://hotjar';
if (!is_dir($directory) || !is_writable($directory)) {
$result = file_prepare_directory($directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
}
if ($result) {
$result = $this
->saveSnippets();
}
else {
$this->messenger
->addWarning($this
->t('Failed to create or make writable the directory %directory, possibly due to a permissions problem. Make the directory writable.', [
'%directory' => $directory,
]));
}
return $result;
}