Skip to content

Commit

Permalink
Merge pull request #112 from pantheon-systems/CMS-388
Browse files Browse the repository at this point in the history
CMS-388 - Drupal 8 compatibility
  • Loading branch information
stovak authored Nov 4, 2021
2 parents 8dc38fb + e3e5a58 commit d892348
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 3 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@
"drupal/search_api_solr": "^4.2.1",
"guzzlehttp/guzzle": "^6",
"http-interop/http-factory-guzzle": "^1.0",
"kint-php/kint": "@stable",
"php-http/guzzle6-adapter": "^2.0",
"kint-php/kint": "@stable"
"psr/event-dispatcher": "^1.0"
},
"require-dev": {
"consolidation/robo": "^3.0",
Expand Down
42 changes: 42 additions & 0 deletions src/Events/PantheonEventDispatcher.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

namespace Drupal\search_api_pantheon\Events;

use Psr\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\EventDispatcher\EventDispatcher as SymfonyEventDispatcher;

/**
* Pantheon Event Dispatcher.
*/
class PantheonEventDispatcher extends SymfonyEventDispatcher implements EventDispatcherInterface {

/**
* @var array
*/
protected $listeners = [];

/**
* @var array
*/
protected $sorted = [];

/**
* Override to fix issues with zero listeners.
*
* @param null $eventName
* Name of the Event in question.
*
* @return array|mixed
* Any listeners or empty array.
*/
public function getListeners($eventName = NULL) {
if (empty($this->listeners)) {
return [];
}

return parent::getListeners(
$eventName
);
}

}
4 changes: 2 additions & 2 deletions src/Services/SolariumClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

namespace Drupal\search_api_pantheon\Services;

use Drupal\search_api_pantheon\Events\PantheonEventDispatcher;
use Psr\Log\LoggerAwareTrait;
use Solarium\Core\Client\Client;
use Solarium\Core\Client\Request;
use Solarium\Core\Client\Response;
use Solarium\Core\Query\QueryInterface;
use Solarium\Core\Query\Result\ResultInterface;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Drupal\Core\Logger\LoggerChannelFactoryInterface;

/**
Expand All @@ -23,7 +23,7 @@ class SolariumClient extends Client {
public function __construct(PantheonGuzzle $guzzle, Endpoint $endpoint, LoggerChannelFactoryInterface $logger_factory) {
parent::__construct(
$guzzle->getPsr18Adapter(),
new EventDispatcher(),
new PantheonEventDispatcher(),
['endpoint' => [$endpoint]]
);
$this->logger = $logger_factory->get('PantheonSolariumClient');
Expand Down

0 comments on commit d892348

Please sign in to comment.