Skip to content

Commit f618513

Browse files
committed
Merge branch 'main' into develop
2 parents 313e9ae + b5140f1 commit f618513

20 files changed

Lines changed: 182 additions & 31 deletions

File tree

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@ Versioning](https://semver.org/spec/v2.0.0.html).
88

99
## [Unreleased]
1010

11+
## [1.3.2]
12+
13+
- [PR-392](https://github.com/itk-dev/os2loop/pull/392)
14+
- Update admin forms to match d11
15+
- Update OIDC container
16+
17+
- [PR-391](https://github.com/itk-dev/os2loop/pull/391)
18+
Mail development setup
1119

1220
## [1.3.1]
1321

docker-compose.oidc.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
11
services:
22
idp-employee:
33
image: ghcr.io/geigerzaehler/oidc-provider-mock:latest
4+
# Let this container be accessible both internally and externally on the same domain.
5+
container_name: idp-employee.${COMPOSE_DOMAIN}
46
networks:
57
- app
68
- frontend
79
labels:
810
- "traefik.enable=true"
911
- "traefik.docker.network=frontend"
1012
- "traefik.http.routers.idp-employee_${COMPOSE_PROJECT_NAME:?}.rule=Host(`idp-employee.${COMPOSE_DOMAIN:?}`)"
11-
- "traefik.http.services.idp-employee_${COMPOSE_PROJECT_NAME:?}.loadbalancer.server.port=9400"
13+
expose:
14+
- "80"
1215
command:
1316
[
17+
"--port",
18+
"80",
1419
"--user-claims",
1520
'{"sub": "user", "email": "user@example.com", "groups": ["authenticated"]}',
1621
"--user-claims",

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ services:
3838
- PHP_MAX_EXECUTION_TIME=30
3939
- PHP_MEMORY_LIMIT=256M
4040
# Depending on the setup, you may have to remove --read-envelope-from from msmtp (cf. https://marlam.de/msmtp/msmtp.html) or use SMTP to send mail
41-
- PHP_SENDMAIL_PATH=/usr/bin/msmtp --host=mail --port=1025 --read-recipients --read-envelope-from
41+
- PHP_SENDMAIL_PATH=/usr/bin/msmtp --host=mail --port=1025 --read-recipients
4242
- DOCKER_HOST_DOMAIN=${COMPOSE_DOMAIN:?}
4343
- PHP_IDE_CONFIG=serverName=localhost
4444
# Let drush know the site uri (makes using --uri redundant)

web/profiles/custom/os2loop/modules/os2loop_alert/src/Form/SettingsForm.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Drupal\os2loop_alert\Form;
44

55
use Drupal\Core\Config\ConfigFactoryInterface;
6+
use Drupal\Core\Config\TypedConfigManagerInterface;
67
use Drupal\Core\Form\ConfigFormBase;
78
use Drupal\Core\Form\FormStateInterface;
89
use Drupal\Core\StringTranslation\StringTranslationTrait;
@@ -40,8 +41,8 @@ final class SettingsForm extends ConfigFormBase {
4041
/**
4142
* Constructor.
4243
*/
43-
public function __construct(ConfigFactoryInterface $config_factory, Settings $settings) {
44-
parent::__construct($config_factory);
44+
public function __construct(ConfigFactoryInterface $config_factory, TypedConfigManagerInterface $typedConfigManager, Settings $settings) {
45+
parent::__construct($config_factory, $typedConfigManager);
4546
$this->settings = $settings;
4647
}
4748

@@ -51,6 +52,7 @@ public function __construct(ConfigFactoryInterface $config_factory, Settings $se
5152
public static function create(ContainerInterface $container) {
5253
return new static(
5354
$container->get('config.factory'),
55+
$container->get('config.typed'),
5456
$container->get(Settings::class)
5557
);
5658
}

web/profiles/custom/os2loop/modules/os2loop_analytics/src/Form/SettingsForm.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Drupal\os2loop_analytics\Form;
44

55
use Drupal\Core\Config\ConfigFactoryInterface;
6+
use Drupal\Core\Config\TypedConfigManagerInterface;
67
use Drupal\Core\Form\ConfigFormBase;
78
use Drupal\Core\Form\FormStateInterface;
89
use Drupal\os2loop_settings\Settings;
@@ -30,8 +31,8 @@ final class SettingsForm extends ConfigFormBase {
3031
/**
3132
* Constructor.
3233
*/
33-
public function __construct(ConfigFactoryInterface $config_factory, Settings $settings) {
34-
parent::__construct($config_factory);
34+
public function __construct(ConfigFactoryInterface $config_factory, TypedConfigManagerInterface $typedConfigManager, Settings $settings) {
35+
parent::__construct($config_factory, $typedConfigManager);
3536
$this->settings = $settings;
3637
}
3738

@@ -41,6 +42,7 @@ public function __construct(ConfigFactoryInterface $config_factory, Settings $se
4142
public static function create(ContainerInterface $container) {
4243
return new static(
4344
$container->get('config.factory'),
45+
$container->get('config.typed'),
4446
$container->get(Settings::class)
4547
);
4648
}

web/profiles/custom/os2loop/modules/os2loop_cookies/src/Form/SettingsForm.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Drupal\os2loop_cookies\Form;
44

55
use Drupal\Core\Config\ConfigFactoryInterface;
6+
use Drupal\Core\Config\TypedConfigManagerInterface;
67
use Drupal\Core\Form\ConfigFormBase;
78
use Drupal\Core\Form\FormStateInterface;
89
use Drupal\os2loop_settings\Settings;
@@ -30,8 +31,8 @@ final class SettingsForm extends ConfigFormBase {
3031
/**
3132
* Constructor.
3233
*/
33-
public function __construct(ConfigFactoryInterface $config_factory, Settings $settings) {
34-
parent::__construct($config_factory);
34+
public function __construct(ConfigFactoryInterface $config_factory, TypedConfigManagerInterface $typedConfigManager, Settings $settings) {
35+
parent::__construct($config_factory, $typedConfigManager);
3536
$this->settings = $settings;
3637
}
3738

@@ -41,6 +42,7 @@ public function __construct(ConfigFactoryInterface $config_factory, Settings $se
4142
public static function create(ContainerInterface $container) {
4243
return new static(
4344
$container->get('config.factory'),
45+
$container->get('config.typed'),
4446
$container->get(Settings::class)
4547
);
4648
}

web/profiles/custom/os2loop/modules/os2loop_documents/src/Form/SettingsForm.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Drupal\os2loop_documents\Form;
44

55
use Drupal\Core\Config\ConfigFactoryInterface;
6+
use Drupal\Core\Config\TypedConfigManagerInterface;
67
use Drupal\Core\DependencyInjection\DependencySerializationTrait;
78
use Drupal\Core\Entity\EntityTypeManagerInterface;
89
use Drupal\Core\Form\ConfigFormBase;
@@ -41,8 +42,8 @@ final class SettingsForm extends ConfigFormBase {
4142
/**
4243
* Constructor.
4344
*/
44-
public function __construct(ConfigFactoryInterface $config_factory, Settings $settings, EntityTypeManagerInterface $entityTypeManager) {
45-
parent::__construct($config_factory);
45+
public function __construct(ConfigFactoryInterface $config_factory, TypedConfigManagerInterface $typedConfigManager, Settings $settings, EntityTypeManagerInterface $entityTypeManager) {
46+
parent::__construct($config_factory, $typedConfigManager);
4647
$this->settings = $settings;
4748
$this->fileStorage = $entityTypeManager->getStorage('file');
4849
}
@@ -53,6 +54,7 @@ public function __construct(ConfigFactoryInterface $config_factory, Settings $se
5354
public static function create(ContainerInterface $container) {
5455
return new static(
5556
$container->get('config.factory'),
57+
$container->get('config.typed'),
5658
$container->get(Settings::class),
5759
$container->get('entity_type.manager')
5860
);

web/profiles/custom/os2loop/modules/os2loop_flag_content/src/Form/SettingsForm.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Drupal\os2loop_flag_content\Form;
44

55
use Drupal\Core\Config\ConfigFactoryInterface;
6+
use Drupal\Core\Config\TypedConfigManagerInterface;
67
use Drupal\Core\Form\ConfigFormBase;
78
use Drupal\Core\Form\FormStateInterface;
89
use Drupal\node\Entity\NodeType;
@@ -31,8 +32,8 @@ final class SettingsForm extends ConfigFormBase {
3132
/**
3233
* Constructor.
3334
*/
34-
public function __construct(ConfigFactoryInterface $config_factory, Settings $settings) {
35-
parent::__construct($config_factory);
35+
public function __construct(ConfigFactoryInterface $config_factory, TypedConfigManagerInterface $typedConfigManager, Settings $settings) {
36+
parent::__construct($config_factory, $typedConfigManager);
3637
$this->settings = $settings;
3738
}
3839

@@ -42,6 +43,7 @@ public function __construct(ConfigFactoryInterface $config_factory, Settings $se
4243
public static function create(ContainerInterface $container) {
4344
return new static(
4445
$container->get('config.factory'),
46+
$container->get('config.typed'),
4547
$container->get(Settings::class)
4648
);
4749
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
services:
2+
os2loop_mail_notifications.send_mail:
3+
class: Drupal\os2loop_mail_notifications\Command\SendMailCommand
4+
arguments:
5+
- "@plugin.manager.mail"
6+
tags:
7+
- { name: console.command }
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Drupal\os2loop_mail_notifications\Command;
6+
7+
use Drupal\Component\Utility\NestedArray;
8+
use Drupal\Core\Mail\MailManagerInterface;
9+
use Drupal\node\Entity\Node;
10+
use Symfony\Component\Console\Attribute\AsCommand;
11+
use Symfony\Component\Console\Command\Command;
12+
use Symfony\Component\Console\Exception\InvalidArgumentException;
13+
use Symfony\Component\Console\Input\InputArgument;
14+
use Symfony\Component\Console\Input\InputInterface;
15+
use Symfony\Component\Console\Input\InputOption;
16+
use Symfony\Component\Console\Output\OutputInterface;
17+
use Symfony\Component\Console\Style\SymfonyStyle;
18+
use Symfony\Component\Yaml\Yaml;
19+
20+
// phpcs:disable Drupal.Commenting.ClassComment.Missing
21+
#[AsCommand(
22+
name: 'os2loop_mail_notifications:mail:send',
23+
description: 'Send a mail',
24+
aliases: ['example'],
25+
)]
26+
final class SendMailCommand extends Command {
27+
28+
public function __construct(
29+
private readonly MailManagerInterface $mailManager,
30+
) {
31+
parent::__construct();
32+
}
33+
34+
/**
35+
* {@inheritdoc}
36+
*/
37+
protected function configure() {
38+
$this
39+
->addArgument('to', InputArgument::REQUIRED, 'The mail recipient')
40+
->addOption('module', NULL, InputOption::VALUE_REQUIRED, 'The module', 'os2loop_flag_content')
41+
->addOption('key', NULL, InputOption::VALUE_REQUIRED, 'The key', 'flag_content')
42+
->addOption('langcode', NULL, InputOption::VALUE_REQUIRED, 'The langcode', 'en')
43+
->addOption('params', NULL, InputOption::VALUE_REQUIRED, 'The params (whatever that may be) as a Yaml object', '{}')
44+
->setHelp(<<<HELP
45+
Examples:
46+
47+
drush %command.name% test@example.com --params '
48+
message: My test message
49+
'
50+
HELP);
51+
}
52+
53+
/**
54+
* {@inheritdoc}
55+
*/
56+
protected function execute(InputInterface $input, OutputInterface $output): int {
57+
$io = new SymfonyStyle($input, $output);
58+
59+
$to = $input->getArgument('to');
60+
$module = $input->getOption('module');
61+
$key = $input->getOption('key');
62+
$langcode = $input->getOption('langcode');
63+
try {
64+
$params = Yaml::parse($input->getOption('params'));
65+
}
66+
catch (\Exception $e) {
67+
throw new InvalidArgumentException(dt('Invalid params: %message', ['%message' => $e->getMessage()]));
68+
}
69+
70+
// @todo Add some useful stuff here.
71+
$defaultParams = match ($module) {
72+
'os2loop_flag_content' => [
73+
'reason' => 'reason',
74+
'message' => __FILE__,
75+
'node' => Node::create([
76+
'type' => 'test',
77+
'nid' => 0,
78+
'title' => __FILE__,
79+
]),
80+
],
81+
default => throw new InvalidArgumentException(dt('Unknown module: %module', ['%module' => $module])),
82+
};
83+
84+
$params = NestedArray::mergeDeep($defaultParams, (array) $params);
85+
86+
$send = TRUE;
87+
$result = $this->mailManager->mail($module, $key, $to, $langcode, $params, NULL, $send);
88+
89+
$success = $result['result'] ?? FALSE;
90+
if ($success) {
91+
$io->success(dt('Mail successfully sent to %to', ['%to' => $to]));
92+
}
93+
else {
94+
$io->error(dt('Error sending mail to %to', ['%to' => $to]));
95+
}
96+
97+
// Show the message data.
98+
$io->writeln(Yaml::dump($result));
99+
100+
return $success ? self::SUCCESS : self::FAILURE;
101+
}
102+
103+
}

0 commit comments

Comments
 (0)