protected function SnippetBuilder::saveSnippets in Hotjar 8
Same name and namespace in other branches
- 8.2 src/SnippetBuilder.php \Drupal\hotjar\SnippetBuilder::saveSnippets()
Saves JS snippet files based on current settings.
Return value
bool Whether the files were saved.
1 call to SnippetBuilder::saveSnippets()
- SnippetBuilder::createAssets in src/
SnippetBuilder.php - Prepares directory for and saves snippet files based on current settings.
File
- src/
SnippetBuilder.php, line 154
Class
- SnippetBuilder
- Class SnippetBuilder.
Namespace
Drupal\hotjarCode
protected function saveSnippets() {
$snippet = $this
->buildSnippet();
$path = file_unmanaged_save_data($snippet, 'public://hotjar/hotjar.script.js', FILE_EXISTS_REPLACE);
if ($path === FALSE) {
$this->messenger
->addMessage($this
->t('An error occurred saving one or more snippet files. Please try again or contact the site administrator if it persists.'));
return FALSE;
}
$this->messenger
->addMessage($this
->t('Created snippet file based on configuration.'));
$this->jsCollectionOptimizer
->deleteAll();
_drupal_flush_css_js();
return TRUE;
}