Skip to content
Snippets Groups Projects

Issue #3482085 by eduardo morales alberti: List medias that could not be retrieve

Open Issue #3482085 by eduardo morales alberti: List medias that could not be retrieve
All threads resolved!
All threads resolved!
Files
6
<?php
namespace Drupal\xray_audit_insight\OEmbed;
use Drupal\media\OEmbed\ResourceFetcherInterface;
use Drupal\media\OEmbed\ResourceException;
use Drupal\xray_audit_insight\XrayAuditInsightReport;
/**
* Decorates the original ResourceFetcher service to add logging capabilities.
*/
class ResourceFetcherDecorator implements ResourceFetcherInterface {
/**
* Constructs a new ResourceFetcherDecorator.
*
* @param \Drupal\media\OEmbed\ResourceFetcherInterface $resourceFetcher
* The original resource fetcher service.
* @param \Drupal\xray_audit_insight\XrayAuditInsightReport $insightReport
* The XrayAuditInsightReport service for logging insights.
*/
public function __construct(
protected ResourceFetcherInterface $resourceFetcher,
protected XrayAuditInsightReport $insightReport,
) {}
/**
* {@inheritdoc}
*/
public function fetchResource($url) {
try {
return $this->resourceFetcher->fetchResource($url);
}
catch (ResourceException $e) {
// Log the exception to the xray_audit_insight table.
$this->insightReport->addInsightData(
'external_resource',
$e->getMessage(),
$url
);
throw $e;
}
}
}
Loading