Skip to content
Snippets Groups Projects
Commit d6235b51 authored by Jürgen Haas's avatar Jürgen Haas
Browse files

Issue #3459183 by jurgenhaas: Fix PHPStan tests for Drupal 11

parent edc2ab0b
Branches
Tags
No related merge requests found
Pipeline #230507 passed
name: Drupal Audit Notification Subscription Event
type: module
description: Event driven framework to audit system activity, create notifications from them and allow users to subscribe to them.
core_version_requirement: ^10 || ^11
core_version_requirement: ^10.3 || ^11
package: DANSE
configure: danse.settings
......
......@@ -4,6 +4,7 @@ namespace Drupal\eca_danse\Event;
use Drupal\Core\Entity\ContentEntityInterface;
use Drupal\Core\Entity\Plugin\DataType\EntityAdapter;
use Drupal\Core\TypedData\Exception\MissingDataException;
use Drupal\eca\Plugin\DataType\DataTransferObject;
/**
......@@ -54,9 +55,13 @@ class RecipientSelection extends BaseEvent {
public function getRecipientsAsList(): array {
$this->init();
$result = [];
foreach ($this->recipients as $item) {
// @todo For D10 the next one always evaluates to false, but in D11 it is
// a reasonable condition. How do we fix that?
try {
$items = $this->recipients->toArray();
}
catch (MissingDataException) {
$items = [];
}
foreach ($items as $item) {
if (is_scalar($item)) {
$result[] = $item;
}
......
......@@ -3,6 +3,7 @@
namespace Drupal\danse\Form;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Config\TypedConfigManagerInterface;
use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\danse\RecipientSelectionManager;
......@@ -33,13 +34,15 @@ final class Settings extends ConfigFormBase {
*
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
* The config factory service.
* @param \Drupal\Core\Config\TypedConfigManagerInterface $typedConfigManager
* The typed config manager.
* @param \Drupal\danse\Service $danse
* The DANSE services.
* @param \Drupal\danse\RecipientSelectionManager $recipient_selection_manager
* The recipient selection plugin manager.
*/
public function __construct(ConfigFactoryInterface $config_factory, Service $danse, RecipientSelectionManager $recipient_selection_manager) {
parent::__construct($config_factory);
public function __construct(ConfigFactoryInterface $config_factory, TypedConfigManagerInterface $typedConfigManager, Service $danse, RecipientSelectionManager $recipient_selection_manager) {
parent::__construct($config_factory, $typedConfigManager);
$this->danse = $danse;
$this->recipientSelectionManager = $recipient_selection_manager;
}
......@@ -50,6 +53,7 @@ final class Settings extends ConfigFormBase {
public static function create(ContainerInterface $container): Settings {
return new Settings(
$container->get('config.factory'),
$container->get('config.typed'),
$container->get('danse.service'),
$container->get('plugin.manager.danse.recipient.selection')
);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment