diff --git a/src/Plugin/ProjectBrowserSource/DrupalDotOrgJsonApi.php b/src/Plugin/ProjectBrowserSource/DrupalDotOrgJsonApi.php index 037814bf3b895bf2e4a0f62c105001de2f1d4357..8e53b48ee3d86464c7964f8cf7ba9edec12c8df1 100644 --- a/src/Plugin/ProjectBrowserSource/DrupalDotOrgJsonApi.php +++ b/src/Plugin/ProjectBrowserSource/DrupalDotOrgJsonApi.php @@ -7,6 +7,7 @@ use Drupal\Component\Serialization\Json; use Drupal\Component\Utility\Html; use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Extension\ExtensionVersion; +use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\StringTranslation\StringTranslationTrait; use Drupal\Core\Url; use Drupal\project_browser\Plugin\ProjectBrowserSourceBase; @@ -81,15 +82,18 @@ final class DrupalDotOrgJsonApi extends ProjectBrowserSourceBase { * The cache bin. * @param \Drupal\Component\Datetime\TimeInterface $time * The time service. + * @param \Drupal\Core\Extension\ModuleHandlerInterface $moduleHandler + * The module handler service. */ public function __construct( array $configuration, $plugin_id, $plugin_definition, - protected LoggerInterface $logger, - protected ClientInterface $httpClient, - protected CacheBackendInterface $cacheBin, - protected TimeInterface $time, + private readonly LoggerInterface $logger, + private readonly ClientInterface $httpClient, + private readonly CacheBackendInterface $cacheBin, + private readonly TimeInterface $time, + private readonly ModuleHandlerInterface $moduleHandler, ) { parent::__construct($configuration, $plugin_id, $plugin_definition); } @@ -106,6 +110,7 @@ final class DrupalDotOrgJsonApi extends ProjectBrowserSourceBase { $container->get(ClientInterface::class), $container->get('cache.project_browser'), $container->get('datetime.time'), + $container->get(ModuleHandlerInterface::class), ); } @@ -184,10 +189,20 @@ final class DrupalDotOrgJsonApi extends ProjectBrowserSourceBase { $this->t('The request made to Drupal.org is likely invalid or might have been blocked. Ensure you are running the latest version of Project Browser') : $this->t('The request made to Drupal.org is likely invalid. Ensure you are running the latest version of Project Browser'); } - $result['message'] = $this->t('@reason. See the error log for details. While this error persists, you can <a href="@drupalorg_catalog">browse modules on Drupal.org</a>.', [ - '@reason' => $reason, - '@drupalorg_catalog' => 'https://www.drupal.org/project/project_module', - ]); + if ($this->moduleHandler->moduleExists('dblog')) { + $dblog_url = Url::fromRoute('dblog.overview')->toString(); + $result['message'] = $this->t('@reason. See the <a href="@dblog_url">error log</a> for details. While this error persists, you can <a href="@drupalorg_catalog">browse modules on Drupal.org</a>.', [ + '@dblog_url' => $dblog_url, + '@reason' => $reason, + '@drupalorg_catalog' => 'https://www.drupal.org/project/project_module', + ]); + } + else { + $result['message'] = $this->t('@reason. See the error log for details. While this error persists, you can <a href="@drupalorg_catalog">browse modules on Drupal.org</a>.', [ + '@reason' => $reason, + '@drupalorg_catalog' => 'https://www.drupal.org/project/project_module', + ]); + } $result['code'] = $error_code; }