Skip to content
Snippets Groups Projects
Commit 2f8a172a authored by Rakesh Kumar Regar's avatar Rakesh Kumar Regar Committed by Kapil Kumar
Browse files

Issue #3392844: Changes not reflacting for anonymous user

parent 9ce4fea4
Branches
Tags
1 merge request!13Issue #3392844: Changes not reflacting for anonymous user
......@@ -34,7 +34,6 @@ function advance_script_manager_help($route_name, RouteMatchInterface $route_mat
*/
function advance_script_manager_page_attachments_alter(array &$attachments) {
$scripts = fetch_scripts('Header');
$renderer = \Drupal::service('renderer');
foreach ($scripts as $key => $header_section) {
// Get paths from DB.
$paths = [];
......@@ -102,7 +101,6 @@ function advance_script_manager_page_attachments_alter(array &$attachments) {
'advance-script-manager-scripts-' . $i,
];
if (!empty($script_attr)) {
$renderer->addCacheableDependency($attachments, $value);
$attachments['#attached']['html_head'][$i][0]['#attributes'] = $script_attr;
}
$i++;
......@@ -157,7 +155,6 @@ function advance_script_manager_page_attachments_alter(array &$attachments) {
}
}
if ($add_to_header) {
$renderer->addCacheableDependency($attachments, $value);
$attachments['#attached']['html_head'][$i][0] = [
'#type' => 'html_tag',
'#tag' => $style_tag,
......@@ -183,8 +180,6 @@ function advance_script_manager_page_attachments_alter(array &$attachments) {
function advance_script_manager_page_top(array &$page_top) {
$scripts = fetch_scripts('Body');
$html = adv_get_content($scripts);
$renderer = \Drupal::service('renderer');
$renderer->addCacheableDependency($page_top, $html);
if ($html) {
$page_top['adv_code'] = [
'#markup' => t($html),
......@@ -201,8 +196,6 @@ function advance_script_manager_page_top(array &$page_top) {
function advance_script_manager_page_bottom(array &$page_bottom) {
$scripts = fetch_scripts('Footer');
$html = adv_get_content($scripts);
$renderer = \Drupal::service('renderer');
$renderer->addCacheableDependency($page_bottom, $html);
if ($html) {
$page_bottom['adv_code'] = [
'#markup' => t($html),
......
......@@ -94,6 +94,7 @@ class ListScriptsFormDeleteMultiple extends ConfirmFormBase {
->condition('id', $id, 'IN')
->execute();
if ($res) {
\Drupal::service('plugin.cache_clearer')->clearCachedDefinitions();
$this->messenger()->addMessage($this->t('Script has been deleted.'));
$form_state->setRedirect('advance_script_manager.advance_script_controller_build');
}
......
......@@ -245,6 +245,7 @@ class ListscriptsForm extends FormBase {
# code...
break;
}
\Drupal::service('plugin.cache_clearer')->clearCachedDefinitions();
}
......
......@@ -234,6 +234,7 @@ class ScriptsForm extends ConfigFormBase {
$this->messenger->addMessage($this->t('Script config saved.'));
}
}
\Drupal::service('plugin.cache_clearer')->clearCachedDefinitions();
$url = Url::fromRoute('advance_script_manager.advance_script_controller_build');
$form_state->setRedirectUrl($url);
}
......
......@@ -92,6 +92,7 @@ class ScriptsFormDelete extends ConfirmFormBase {
->condition('id', $id, '=')
->execute();
if ($res) {
\Drupal::service('plugin.cache_clearer')->clearCachedDefinitions();
$this->messenger()->addMessage($this->t('Script has been deleted.'));
$form_state->setRedirect('advance_script_manager.advance_script_controller_build');
}
......
......@@ -153,6 +153,7 @@ class ScriptsOrderForm extends FormBase {
->condition('id', $id, '=')
->execute();
}
\Drupal::service('plugin.cache_clearer')->clearCachedDefinitions();
$this->messenger()->addMessage($this->t('Order saved'));
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment