Skip to content

Commit

Permalink
PROD-29620: Replace all EDA Handlers with dummies if there is no Publ…
Browse files Browse the repository at this point in the history
…isher
  • Loading branch information
tregismoreira committed Aug 2, 2024
1 parent dae8904 commit e8f7c7e
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 6 deletions.
18 changes: 18 additions & 0 deletions modules/social_features/social_core/src/EdaDummyHandler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace Drupal\social_core;

/**
* A dummy handler that equals a no-op.
*
* This ensures people who do not use the EDA to publish events to an external
* event bus don't have any performance penalty from loading or formatting data.
*/
class EdaDummyHandler {

/**
* {@inheritDoc}
*/
public function __call(string $name, array $arguments): void {}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Drupal\Core\DependencyInjection\ServiceProviderBase;
use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\social_eda_dispatcher\Dispatcher as SocialEdaDispatcher;

/**
* Class SocialCoreServiceProvider.
Expand All @@ -15,7 +16,7 @@ class SocialCoreServiceProvider extends ServiceProviderBase {
/**
* {@inheritdoc}
*/
public function alter(ContainerBuilder $container) {
public function alter(ContainerBuilder $container): void {
// Overrides language_manager class to test domain language negotiation.
$definition = $container->getDefinition('entity.autocomplete_matcher');
$definition->setClass('Drupal\social_core\Entity\EntityAutocompleteMatcher');
Expand All @@ -29,6 +30,14 @@ public function alter(ContainerBuilder $container) {
$definition->setClass('Drupal\social_core\Entity\Select2EntityAutocompleteMatcher');
}
}

// Replaces all EDA Handlers with dummies if there is no Publisher.
if (!$container->hasDefinition(SocialEdaDispatcher::class)) {
foreach ($container->findTaggedServiceIds('social.eda.handler') as $id => $attributes) {
$definition = $container->getDefinition($id);
$definition->setClass(EdaDummyHandler::class);
}
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,5 @@ services:
social_event.eda_handler:
autowire: true
class: Drupal\social_event\EdaHandler
tags:
- { name: social.eda.handler }
10 changes: 5 additions & 5 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -4763,11 +4763,6 @@ parameters:
count: 1
path: modules/social_features/social_core/src/Routing/RouteSubscriber.php

-
message: "#^Method Drupal\\\\social_core\\\\SocialCoreServiceProvider\\:\\:alter\\(\\) has no return type specified\\.$#"
count: 1
path: modules/social_features/social_core/src/SocialCoreServiceProvider.php

-
message: "#^Method Drupal\\\\social_download_count\\\\SocialDownloadCountConfigOverride\\:\\:createConfigObject\\(\\) should return Drupal\\\\Core\\\\Config\\\\StorableConfigBase but returns null\\.$#"
count: 1
Expand Down Expand Up @@ -13400,3 +13395,8 @@ parameters:
message: "#^Property Drupal\\\\social_event\\\\Event\\\\EventCreateEventData::\\$href has unknown class Drupal\\\\social_eda\\\\Types\\\\Href as its type\\.$#"
count: 1
path: modules/social_features/social_event/src/Event/EventCreateEventData.php

-
message: "#^Class Drupal\\\\social_eda_dispatcher\\\\Dispatcher not found\\.$#"
count: 1
path: modules/social_features/social_core/src/SocialCoreServiceProvider.php

0 comments on commit e8f7c7e

Please sign in to comment.