Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update from upstream #4

Merged
merged 1 commit into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@ $config['gtm_barebones.settings']['environment_id'] = 'env-123456';
$config['gtm_barebones.settings']['environment_token'] = 'iBN8NANliiuqnAAi81LapqkkdUIjak';
```

# CSP (Content Security Policy)

If your site enforces CSP, you must add configure CSP directives.

Consider using the [CSP module](https://www.drupal.org/project/csp)

Then add the directives in https://developers.google.com/tag-platform/security/guides/csp

Note the extra directives required for things like Preview mode, and Google Analytics integration.

## License

This program is free software; you can redistribute it and/or modify
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "OCHA fork of GTM Barebones.",
"type": "drupal-module",
"require": {
"php": ">=8.1",
"drupal/core": "^9.5 || ^10"
"php": ">=8.2",
"drupal/core": "^10.2 || ^11"
}
}
6 changes: 2 additions & 4 deletions gtm_barebones.info.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
name: Barebones GTM (OCHA)
type: module
description: Just the essentials.
core_version_requirement: ^9.5 || ^10
php: 8.1
core_version_requirement: ^10.2 || ^11
php: 8.2
package: SEO
dependencies:
- drupal:system (>=8.6)
4 changes: 2 additions & 2 deletions gtm_barebones.module
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use Drupal\gtm_barebones\Hooks\GtmBarebonesHooks;
*/
function gtm_barebones_page_attachments(array &$attachments): void {
/** @var \Drupal\gtm_barebones\Hooks\GtmBarebonesHooks $hooks */
$hooks = \Drupal::classResolver(GtmBarebonesHooks::class);
$hooks = \Drupal::service(GtmBarebonesHooks::class);
$hooks->pageAttachments($attachments);
}

Expand All @@ -18,6 +18,6 @@ function gtm_barebones_page_attachments(array &$attachments): void {
*/
function gtm_barebones_page_top(array &$page_top): void {
/** @var \Drupal\gtm_barebones\Hooks\GtmBarebonesHooks $hooks */
$hooks = \Drupal::classResolver(GtmBarebonesHooks::class);
$hooks = \Drupal::service(GtmBarebonesHooks::class);
$hooks->pageTop($page_top);
}
6 changes: 6 additions & 0 deletions gtm_barebones.services.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
services:
_defaults:
autowire: true
autoconfigure: true

Drupal\gtm_barebones\Hooks\GtmBarebonesHooks: ~

gtm_barebones.gtm_controller:
class: \Drupal\gtm_barebones\Controller\GtmBarebonesController
16 changes: 2 additions & 14 deletions src/Hooks/GtmBarebonesHooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,23 @@

use Drupal\Core\Cache\CacheableMetadata;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
use Drupal\Core\Render\Markup;
use Drupal\Core\Routing\AdminContext;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
* Hooks.
*/
final class GtmBarebonesHooks implements ContainerInjectionInterface {
final class GtmBarebonesHooks {

/**
* Constructor.
*/
private function __construct(
public function __construct(
private readonly ConfigFactoryInterface $configFactory,
protected AdminContext $adminContext,
) {
}

/**
* {@inheritdoc}
*/
final public static function create(ContainerInterface $container): static {
return new static(
$container->get('config.factory'),
$container->get('router.admin_context'),
);
}

/**
* Implements hook_page_attachments().
*
Expand Down