Commit 9c4b985f authored by Robert Kasza's avatar Robert Kasza Committed by Robert Kasza
Browse files

Issue #3146542 by Gnanagowthaman sankar, Rishi Kulshreshtha, szeidler,...

Issue #3146542 by Gnanagowthaman sankar, Rishi Kulshreshtha, szeidler, drupal.ninja03, vetal4ik, Kakoum, NicholasS, slv_, isa.bel, osopolar, Rajab Natshah, siddhant.bhosale, kaszarobert, ericdsd: Drupal 9 Compatibility for Google Analytics Counter module
parent 7fcb311c
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
name: 'Google Analytics Counter'
type: module
description: 'Lightweight page view counter drawing on data collected by Google Analytics.'
core: 8.x
core_version_requirement: ^8 || ^9
package: Statistics
configure: google_analytics_counter.admin_settings_form
dependencies:
+1 −1
Original line number Diff line number Diff line
@@ -237,7 +237,7 @@ function google_analytics_counter_update_8009() {
  $config_factory = \Drupal::configFactory();

  // Get the content types.
  $content_types = \Drupal::service('entity.manager')
  $content_types = \Drupal::service('entity_type.manager')
    ->getStorage('node_type')
    ->loadMultiple();

+2 −2
Original line number Diff line number Diff line
@@ -4,7 +4,7 @@ services:

  google_analytics_counter.app_manager:
    class: \Drupal\google_analytics_counter\GoogleAnalyticsCounterAppManager
    arguments: ['@config.factory', '@database', '@state', '@path.alias_manager', '@path.matcher', '@language_manager', '@logger.channel.google_analytics_counter', '@messenger', '@google_analytics_counter.auth_manager']
    arguments: ['@config.factory', '@database', '@state', '@path_alias.manager', '@path.matcher', '@language_manager', '@logger.channel.google_analytics_counter', '@messenger', '@google_analytics_counter.auth_manager']

  google_analytics_counter.auth_manager:
    class: \Drupal\google_analytics_counter\GoogleAnalyticsCounterAuthManager
+7 −3
Original line number Diff line number Diff line
@@ -140,7 +140,8 @@ class GoogleAnalyticsCounterController extends ControllerBase {

    // Get and format total pageviews.
    $t_args = $this->messageManager->setStartDateEndDate();
    $t_args += ['%total_pageviews' => number_format($this->state->get('google_analytics_counter.total_pageviews'))];
    $totalViews = $this->state->get('google_analytics_counter.total_pageviews') ?? 0;
    $t_args += ['%total_pageviews' => number_format($totalViews)];
    $build['google_info']['total_pageviews'] = [
      '#type' => 'html_tag',
      '#tag' => 'p',
@@ -149,8 +150,9 @@ class GoogleAnalyticsCounterController extends ControllerBase {

    // Get and format total paths.
    $t_args = $this->messageManager->setStartDateEndDate();
    $totalPaths = $this->state->get('google_analytics_counter.total_paths') ?? 0;
    $t_args += [
      '%total_paths' => number_format($this->state->get('google_analytics_counter.total_paths')),
      '%total_paths' => number_format($totalPaths),
    ];
    $build['google_info']['total_paths'] = [
      '#type' => 'html_tag',
@@ -216,10 +218,12 @@ class GoogleAnalyticsCounterController extends ControllerBase {
      '#value' => $this->t('%num_of_results paths are currently stored in the local database table.', ['%num_of_results' => number_format(GoogleAnalyticsCounterHelper::getCount('google_analytics_counter'))]),
    ];

    $totalNodes = $this->state->get('google_analytics_counter.total_nodes') ?? 0;

    $build['drupal_info']['total_nodes'] = [
      '#type' => 'html_tag',
      '#tag' => 'p',
      '#value' => $this->t('%totalnodes nodes are published on this site.', ['%totalnodes' => number_format($this->state->get('google_analytics_counter.total_nodes'))]),
      '#value' => $this->t('%totalnodes nodes are published on this site.', ['%totalnodes' => number_format($totalNodes)]),
    ];

    $build['drupal_info']['total_nodes_with_pageviews'] = [
+1 −1
Original line number Diff line number Diff line
@@ -179,7 +179,7 @@ class GoogleAnalyticsCounterAuthForm extends ConfigFormBase {
    ];

    $current_path = \Drupal::service('path.current')->getPath();
    $uri = \Drupal::service('path.alias_manager')->getAliasByPath($current_path);
    $uri = \Drupal::service('path_alias.manager')->getAliasByPath($current_path);
    $description = $this->t('The path that users are redirected to after they have authenticated with Google.<br /> Default: <strong>@default_uri</strong>', ['@default_uri' => $base_url . $uri]);
    $form['redirect_uri'] = [
      '#type' => 'textfield',
Loading