From c86ff97fe08b2b6a266e31a814748568f9e6a74a Mon Sep 17 00:00:00 2001 From: rpnykanen Date: Wed, 27 Sep 2023 07:59:46 +0300 Subject: [PATCH 1/2] UHF-9020: updated api url. added helfi platform config wide logging service. Updated failing request to use logging service --- helfi_platform_config.services.yml | 5 +++++ .../ExternalEntities/StorageClient/Hearings.php | 14 +++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/helfi_platform_config.services.yml b/helfi_platform_config.services.yml index 1396d3a41..cc005d4a3 100644 --- a/helfi_platform_config.services.yml +++ b/helfi_platform_config.services.yml @@ -45,3 +45,8 @@ services: class: Drupal\helfi_platform_config\Routing\TermRouteSubscriber tags: - { name: event_subscriber } + + logger.channel.helfi_platform_config: + parent: logger.channel_base + arguments: + - 'helfi_platform_config' diff --git a/modules/helfi_paragraphs_hearings/src/Plugin/ExternalEntities/StorageClient/Hearings.php b/modules/helfi_paragraphs_hearings/src/Plugin/ExternalEntities/StorageClient/Hearings.php index fb9cb3649..38fac15c5 100644 --- a/modules/helfi_paragraphs_hearings/src/Plugin/ExternalEntities/StorageClient/Hearings.php +++ b/modules/helfi_paragraphs_hearings/src/Plugin/ExternalEntities/StorageClient/Hearings.php @@ -15,6 +15,7 @@ use GuzzleHttp\Exception\InvalidArgumentException; use GuzzleHttp\Exception\RequestException; use GuzzleHttp\Utils; +use Psr\Log\LoggerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -28,7 +29,7 @@ */ final class Hearings extends ExternalEntityStorageClientBase { - public const API_URL = 'https://api.hel.fi/kerrokantasi/v1/hearing?'; + public const API_URL = 'https://kerrokantasi.api.hel.fi/v1/hearing?'; public const HEARING_URL = 'https://kerrokantasi.hel.fi/'; @@ -46,6 +47,13 @@ final class Hearings extends ExternalEntityStorageClientBase { */ private ClientInterface $client; + /** + * The logger. + * + * @var \Psr\Log\LoggerInterface + */ + private LoggerInterface $logger; + /** * {@inheritdoc} */ @@ -58,7 +66,7 @@ public static function create( $instance = parent::create($container, $configuration, $plugin_id, $plugin_definition); $instance->languageManager = $container->get('language_manager'); $instance->client = $container->get('http_client'); - + $instance->logger = $container->get('logger.channel.helfi_platform_config'); return $instance; } @@ -114,7 +122,7 @@ public function query( } } catch (RequestException | GuzzleException | InvalidArgumentException $e) { - watchdog_exception('helfi_paragraphs_hearings', $e); + $this->logger->error('Hearings request failed with error: ' . $e->getMessage()); return []; } From e7aabbe45ddcd22de21e24d5367b633b0f7d9e2c Mon Sep 17 00:00:00 2001 From: rpnykanen Date: Wed, 27 Sep 2023 08:00:15 +0300 Subject: [PATCH 2/2] UHF-9020: updated readme file --- modules/helfi_paragraphs_hearings/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/helfi_paragraphs_hearings/README.md b/modules/helfi_paragraphs_hearings/README.md index 60f558e4b..e6dd70058 100644 --- a/modules/helfi_paragraphs_hearings/README.md +++ b/modules/helfi_paragraphs_hearings/README.md @@ -2,7 +2,7 @@ Get hearings from "Kerrokantasi" service Site: https://kerrokantasi.hel.fi/hearings/list?lang=en -Api: https://api.hel.fi/kerrokantasi/v1/hearing?format=json&langcode=fi&open=true (with query parameters) +Api: https://kerrokantasi.api.hel.fi/v1/hearing?format=json&langcode=fi&open=true (with query parameters) ## Helfi_hearings - Uses external entity to fetch hearings