Skip to content

Commit

Permalink
UHF-11071: Test external_entities v3 upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
hyrsky committed Feb 21, 2025
1 parent 6598bfa commit 9d6c73d
Show file tree
Hide file tree
Showing 12 changed files with 52 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ protected function getRemoteEntities(): array {
$entityStorage = $this->getExternalEntityStorage('helfi_announcements');
$nodes = [];

/** @var \Drupal\external_entities\ExternalEntityInterface $announcement */
/** @var \Drupal\external_entities\Entity\ExternalEntityInterface $announcement */
foreach ($entityStorage->loadMultiple() as $announcement) {
$linkUrl = NULL;
$linkText = NULL;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ protected function getRemoteEntities(): array {
$entityStorage = $this->getExternalEntityStorage('helfi_surveys');
$nodes = [];

/** @var \Drupal\external_entities\ExternalEntityInterface $entity */
/** @var \Drupal\external_entities\Entity\ExternalEntityInterface $entity */
foreach ($entityStorage->loadMultiple() as $entity) {
$linkUrl = NULL;
$linkText = NULL;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
/**
* External entity storage client for News feed entities.
*
* @ExternalEntityStorageClient(
* @StorageClient(
* id = "helfi_announcements",
* label = @Translation("Helfi: Announcements"),
* description = @Translation("Retrieves announcements from helfi")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
use Drupal\Core\Language\LanguageInterface;
use Drupal\Core\Language\LanguageManagerInterface;
use Drupal\Core\Utility\Error;
use Drupal\external_entities\ExternalEntityInterface;
use Drupal\external_entities\StorageClient\ExternalEntityStorageClientBase;
use Drupal\external_entities\Entity\ExternalEntityInterface;
use Drupal\external_entities\StorageClient\StorageClientBase;
use Drupal\helfi_api_base\Environment\Environment;
use Drupal\helfi_api_base\Environment\Project;
use Drupal\helfi_api_base\Language\DefaultLanguageResolver;
Expand All @@ -20,15 +20,12 @@
use GuzzleHttp\Psr7\Query;
use GuzzleHttp\Utils;
use Psr\Log\LoggerAwareInterface;
use Psr\Log\LoggerAwareTrait;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
* Base class for etusivu external entity storage client.
*/
abstract class EtusivuJsonApiEntityBase extends ExternalEntityStorageClientBase implements LoggerAwareInterface {

use LoggerAwareTrait;
abstract class EtusivuJsonApiEntityBase extends StorageClientBase implements LoggerAwareInterface {

/**
* Custom cache tag.
Expand Down Expand Up @@ -92,7 +89,6 @@ public static function create(
}
catch (\InvalidArgumentException) {
}
$instance->setLogger($container->get('logger.channel.helfi_etusivu_entities'));

return $instance;
}
Expand Down Expand Up @@ -225,4 +221,19 @@ protected function queryDefaultLangcode(): array {
];
}

/**
* {@inheritDoc}
*/
public function transliterateDrupalFilters(
array $parameters,
array $context = [],
) :array {
// @todo Check performance of this implementation UHF-11477.
return $this->transliterateDrupalFiltersAlter(
['source' => [], 'drupal' => $parameters],
$parameters,
$context
);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
/**
* External entity storage client for News feed entities.
*
* @ExternalEntityStorageClient(
* @StorageClient(
* id = "helfi_surveys",
* label = @Translation("Helfi: Surveys"),
* description = @Translation("Retrieves surveys from helfi")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,23 @@

use Drupal\Core\Language\LanguageInterface;
use Drupal\Core\Language\LanguageManagerInterface;
use Drupal\external_entities\ExternalEntityInterface;
use Drupal\external_entities\StorageClient\ExternalEntityStorageClientBase;
use Drupal\external_entities\Entity\ExternalEntityInterface;
use Drupal\external_entities\StorageClient\StorageClientBase;
use GuzzleHttp\ClientInterface;
use GuzzleHttp\Utils;
use Psr\Log\LoggerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
* Extrernal entity storage client for LinkedEvents events.
* External entity storage client for LinkedEvents events.
*
* @ExternalEntityStorageClient(
* @StorageClient(
* id = "linkedevents_events",
* label = @Translation("LinkedEvents: Events"),
* description = @Translation("Retrieves 'events' content from LinkedEvents")
* )
*/
class Events extends ExternalEntityStorageClientBase {
class Events extends StorageClientBase {
protected const API_URL = 'https://api.hel.fi/linkedevents/v1';
protected const EVENTS_BASE_URL = 'https://tapahtumat.hel.fi/';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
use Drupal\Core\Language\LanguageInterface;
use Drupal\Core\Language\LanguageManagerInterface;
use Drupal\Core\Url;
use Drupal\external_entities\ExternalEntityInterface;
use Drupal\external_entities\StorageClient\ExternalEntityStorageClientBase;
use Drupal\external_entities\Entity\ExternalEntityInterface;
use Drupal\external_entities\StorageClient\StorageClientBase;
use GuzzleHttp\ClientInterface;
use GuzzleHttp\Exception\GuzzleException;
use GuzzleHttp\Exception\InvalidArgumentException;
Expand All @@ -27,7 +27,7 @@
* description = @Translation("Retrieves hearings from hearing api")
* )
*/
final class Hearings extends ExternalEntityStorageClientBase {
final class Hearings extends StorageClientBase {

public const API_URL = 'https://kerrokantasi.api.hel.fi/v1/hearing?';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,17 @@
namespace Drupal\helfi_paragraphs_news_list;

use Drupal\Core\Utility\Error;
use Drupal\external_entities\ExternalEntityInterface;
use Drupal\external_entities\StorageClient\ExternalEntityStorageClientBase;
use Drupal\external_entities\Entity\ExternalEntityInterface;
use Drupal\external_entities\StorageClient\StorageClientBase;
use Elastic\Elasticsearch\Client;
use Elastic\Elasticsearch\Exception\ElasticsearchException;
use Elastic\Transport\Exception\TransportException;
use Psr\Log\LoggerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
* Base class used by taxonomy external entity.
*/
abstract class ElasticExternalEntityBase extends ExternalEntityStorageClientBase {
abstract class ElasticExternalEntityBase extends StorageClientBase {

/**
* Which endpoint to query.
Expand All @@ -32,13 +31,6 @@ abstract class ElasticExternalEntityBase extends ExternalEntityStorageClientBase
*/
protected Client $client;

/**
* The logger.
*
* @var \Psr\Log\LoggerInterface
*/
protected LoggerInterface $logger;

/**
* {@inheritdoc}
*/
Expand All @@ -50,7 +42,6 @@ public static function create(
) : self {
$instance = parent::create($container, $configuration, $plugin_id, $plugin_definition);
$instance->client = $container->get('helfi_paragraphs_news_list.elastic_client');
$instance->logger = $container->get('logger.factory')->get('helfi_external_entity');

return $instance;
}
Expand Down Expand Up @@ -280,4 +271,19 @@ public function query(
return $data['hits']['hits'];
}

/**
* {@inheritDoc}
*/
public function transliterateDrupalFilters(
array $parameters,
array $context = [],
) :array {
// @todo Check performance of this implementation UHF-11477.
return $this->transliterateDrupalFiltersAlter(
['source' => [], 'drupal' => $parameters],
$parameters,
$context
);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
/**
* External entity storage client for News feed entities.
*
* @ExternalEntityStorageClient(
* @StorageClient(
* id = "helfi_news",
* label = @Translation("Helfi: News"),
* description = @Translation("Retrieves 'news' content from Helfi")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
/**
* External entity storage client for News groups taxonomy terms.
*
* @ExternalEntityStorageClient(
* @StorageClient(
* id = "helfi_news_groups",
* label = @Translation("Helfi: News groups"),
* description = @Translation("Retrieves news groups taxonomy terms from Helfi")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
/**
* External entity storage client for News neighbourhoods taxonomy terms.
*
* @ExternalEntityStorageClient(
* @StorageClient(
* id = "helfi_news_neighbourhoods",
* label = @Translation("Helfi: News neighbourhoods"),
* description = @Translation("Retrieves news neighbourhoods taxonomy terms from Helfi")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
/**
* External entity storage client for News tags taxonomy terms.
*
* @ExternalEntityStorageClient(
* @StorageClient(
* id = "helfi_news_tags",
* label = @Translation("Helfi: News tags"),
* description = @Translation("Retrieves news tags taxonomy terms from Helfi")
Expand Down

0 comments on commit 9d6c73d

Please sign in to comment.