Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • wcms/uw_cfg_common
1 result
Show changes
Commits on Source (8)
Showing
with 134 additions and 33 deletions
...@@ -30,6 +30,7 @@ settings: ...@@ -30,6 +30,7 @@ settings:
items: items:
- DrupalLink - DrupalLink
- DrupalUnlink - DrupalUnlink
- Anchor
plugins: plugins:
language: language:
language_list: un language_list: un
......
...@@ -26,6 +26,7 @@ settings: ...@@ -26,6 +26,7 @@ settings:
items: items:
- DrupalLink - DrupalLink
- DrupalUnlink - DrupalUnlink
- Anchor
- -
name: Lists name: Lists
items: items:
......
...@@ -44,6 +44,7 @@ settings: ...@@ -44,6 +44,7 @@ settings:
items: items:
- DrupalLink - DrupalLink
- DrupalUnlink - DrupalUnlink
- Anchor
- -
name: Inserts name: Inserts
items: items:
......
...@@ -18,5 +18,5 @@ selection_criteria: ...@@ -18,5 +18,5 @@ selection_criteria:
taxonomy_term: taxonomy_term taxonomy_term: taxonomy_term
uuid: 2352a426-ffc2-43c1-93ae-f6c8a726cbd3 uuid: 2352a426-ffc2-43c1-93ae-f6c8a726cbd3
selection_logic: and selection_logic: and
weight: -4 weight: -2
relationships: { } relationships: { }
...@@ -18,5 +18,5 @@ selection_criteria: ...@@ -18,5 +18,5 @@ selection_criteria:
taxonomy_term: taxonomy_term taxonomy_term: taxonomy_term
uuid: c3139779-798a-4754-957a-35fba9bd29e3 uuid: c3139779-798a-4754-957a-35fba9bd29e3
selection_logic: and selection_logic: and
weight: 0 weight: 2
relationships: { } relationships: { }
...@@ -18,5 +18,5 @@ selection_criteria: ...@@ -18,5 +18,5 @@ selection_criteria:
taxonomy_term: taxonomy_term taxonomy_term: taxonomy_term
uuid: f4c229ad-5155-4814-8d09-251af2ccf6ed uuid: f4c229ad-5155-4814-8d09-251af2ccf6ed
selection_logic: and selection_logic: and
weight: 2 weight: 4
relationships: { } relationships: { }
...@@ -18,5 +18,5 @@ selection_criteria: ...@@ -18,5 +18,5 @@ selection_criteria:
taxonomy_term: taxonomy_term taxonomy_term: taxonomy_term
uuid: d9203b0b-0816-4e91-b14a-db0e4c905d3e uuid: d9203b0b-0816-4e91-b14a-db0e4c905d3e
selection_logic: and selection_logic: and
weight: 1 weight: 3
relationships: { } relationships: { }
langcode: en
status: true
dependencies:
module:
- node
id: uw_path_contact
label: 'Contact path pattern'
type: 'canonical_entities:node'
pattern: 'contacts/[node:title]'
selection_criteria:
13ad4ca2-9556-4f2f-89fc-45501bae3153:
id: node_type
bundles:
uw_ct_contact: uw_ct_contact
negate: false
context_mapping:
node: node
uuid: 13ad4ca2-9556-4f2f-89fc-45501bae3153
selection_logic: and
weight: -5
relationships: { }
...@@ -9,5 +9,5 @@ type: 'canonical_entities:node' ...@@ -9,5 +9,5 @@ type: 'canonical_entities:node'
pattern: '[node:menu-link:parent:url:path]/[node:title]' pattern: '[node:menu-link:parent:url:path]/[node:title]'
selection_criteria: { } selection_criteria: { }
selection_logic: and selection_logic: and
weight: -5 weight: -3
relationships: { } relationships: { }
...@@ -9,5 +9,5 @@ type: 'canonical_entities:block_content' ...@@ -9,5 +9,5 @@ type: 'canonical_entities:block_content'
pattern: 'blocks/[block_content:info]' pattern: 'blocks/[block_content:info]'
selection_criteria: { } selection_criteria: { }
selection_logic: and selection_logic: and
weight: 6 weight: 8
relationships: { } relationships: { }
...@@ -18,5 +18,5 @@ selection_criteria: ...@@ -18,5 +18,5 @@ selection_criteria:
taxonomy_term: taxonomy_term taxonomy_term: taxonomy_term
uuid: 391bcba7-aaaf-48f2-9045-d6b4279e2c69 uuid: 391bcba7-aaaf-48f2-9045-d6b4279e2c69
selection_logic: and selection_logic: and
weight: -1 weight: 1
relationships: { } relationships: { }
...@@ -18,5 +18,5 @@ selection_criteria: ...@@ -18,5 +18,5 @@ selection_criteria:
taxonomy_term: taxonomy_term taxonomy_term: taxonomy_term
uuid: f991675b-525d-4fc0-878b-1d1746da5a97 uuid: f991675b-525d-4fc0-878b-1d1746da5a97
selection_logic: and selection_logic: and
weight: -2 weight: 0
relationships: { } relationships: { }
...@@ -18,5 +18,5 @@ selection_criteria: ...@@ -18,5 +18,5 @@ selection_criteria:
taxonomy_term: taxonomy_term taxonomy_term: taxonomy_term
uuid: e3bc433f-3689-4dee-aa47-50734405844c uuid: e3bc433f-3689-4dee-aa47-50734405844c
selection_logic: and selection_logic: and
weight: 3 weight: 5
relationships: { } relationships: { }
...@@ -9,5 +9,5 @@ type: 'canonical_entities:media' ...@@ -9,5 +9,5 @@ type: 'canonical_entities:media'
pattern: 'media/[media:name]' pattern: 'media/[media:name]'
selection_criteria: { } selection_criteria: { }
selection_logic: and selection_logic: and
weight: 5 weight: 7
relationships: { } relationships: { }
...@@ -18,5 +18,5 @@ selection_criteria: ...@@ -18,5 +18,5 @@ selection_criteria:
taxonomy_term: taxonomy_term taxonomy_term: taxonomy_term
uuid: 2d47e618-a761-4634-b743-f6924f2b81bf uuid: 2d47e618-a761-4634-b743-f6924f2b81bf
selection_logic: and selection_logic: and
weight: -3 weight: -1
relationships: { } relationships: { }
langcode: en
status: true
dependencies:
module:
- node
id: uw_path_profile
label: 'Profile path pattern'
type: 'canonical_entities:node'
pattern: 'profiles/[node:title]'
selection_criteria:
0f8a9aae-cf05-4d9b-9dd9-a128ce9fa7cf:
id: node_type
bundles:
uw_ct_profile: uw_ct_profile
negate: false
context_mapping:
node: node
uuid: 0f8a9aae-cf05-4d9b-9dd9-a128ce9fa7cf
selection_logic: and
weight: -4
relationships: { }
...@@ -9,5 +9,5 @@ type: 'canonical_entities:taxonomy_term' ...@@ -9,5 +9,5 @@ type: 'canonical_entities:taxonomy_term'
pattern: '[term:vocabulary]/[term:name]' pattern: '[term:vocabulary]/[term:name]'
selection_criteria: { } selection_criteria: { }
selection_logic: and selection_logic: and
weight: 4 weight: 6
relationships: { } relationships: { }
...@@ -9,5 +9,5 @@ type: 'canonical_entities:user' ...@@ -9,5 +9,5 @@ type: 'canonical_entities:user'
pattern: 'users/[user:account-name]' pattern: 'users/[user:account-name]'
selection_criteria: { } selection_criteria: { }
selection_logic: and selection_logic: and
weight: 7 weight: 9
relationships: { } relationships: { }
<?php
namespace Drupal\uw_cfg_common\Service;
use Drupal\Core\Routing\AdminContext;
use Drupal\Core\Routing\RouteMatchInterface;
/**
* Class UWAnalytics.
*
* Service to check if analytics scripts should be included on the page.
*
* @package Drupal\uw_cfg_common\Service
*/
class UWAnalytics {
/**
* Admin context service.
*
* @var \Drupal\Core\Routing\AdminContext
*/
protected $adminContext;
/**
* The route match.
*
* @var \Drupal\Core\Routing\RouteMatchInterface
*/
protected $routeMatch;
/**
* UWAnalytics default constructor.
*
* @param \Drupal\Core\Routing\AdminContext $adminContext
* Admin context, route matcher included.
* @param \Drupal\Core\Routing\RouteMatchInterface $routeMatch
* Route match service.
*/
public function __construct(AdminContext $adminContext, RouteMatchInterface $routeMatch) {
$this->adminContext = $adminContext;
$this->routeMatch = $routeMatch;
}
/**
* Is current page admin page, with additional checks.
*
* @return bool
* TRUE if admin page, FALSE otherwise.
*/
public function administrationPage(): bool {
// Check if requested route is admin route. This should cover /node/1/edit,
// node/1/revisions, term/1/edit, webform results page.
$result = $this->adminContext->isAdminRoute();
// When current route is not detected as admin path, check if route is
// 403 or 404. Skip injecting GA code snippets on those pages.
if (!$result) {
$route_name = $this->routeMatch->getRouteName();
// Check for default 403/404 pages. This will not cover any custom 403/404
// pages that may be webpages (e.g. /node/3).
if (in_array($route_name, ['system.403', 'system.404'])) {
$result = TRUE;
}
// Adding exception for layout builder.
elseif (substr($route_name, 0, 15) == 'layout_builder.') {
$result = TRUE;
}
}
return $result;
}
}
...@@ -349,28 +349,10 @@ function uw_cfg_common_page_attachments(array &$page) { ...@@ -349,28 +349,10 @@ function uw_cfg_common_page_attachments(array &$page) {
$page['#attached']['html_head'][] = [$data, 'uw-google-site-verification']; $page['#attached']['html_head'][] = [$data, 'uw-google-site-verification'];
} }
// Check if requested route is admin route. This should cover /node/1/edit, $admin_page = \Drupal::service('uw_cfg_common.uw_analytics')->administrationPage();
// node/1/revisions, term/1/edit, webform results page.
$skip_ga_snippet = \Drupal::service('router.admin_context')->isAdminRoute();
// When current route is not detected as admin path, check if route is
// 403 or 404. Skip injecting GA code snippets on those pages.
if (!$skip_ga_snippet) {
$route_name = \Drupal::routeMatch()->getRouteName();
// Check for default 403/404 pages. This will not cover any custom 403/404
// pages that may be webpages (e.g. /node/3).
if (in_array($route_name, ['system.403', 'system.404'])) {
$skip_ga_snippet = TRUE;
}
// Adding exception for layout builder.
elseif (substr($route_name, 0, 15) == 'layout_builder.') {
$skip_ga_snippet = TRUE;
}
}
// Get the code from config and inject to the page. // Get the code from config and inject to the page.
if (!$skip_ga_snippet && !empty($config->get('uw_cfg_common_ga_account'))) { if (!$admin_page && !empty($config->get('uw_cfg_common_ga_account'))) {
$code = Html::escape($config->get('uw_cfg_common_ga_account')); $code = Html::escape($config->get('uw_cfg_common_ga_account'));
$firstLetter = strtolower(substr($code, 0, 1)); $firstLetter = strtolower(substr($code, 0, 1));
......