Skip to content
Snippets Groups Projects
Commit ef33ac19 authored by Claudiu Cristea's avatar Claudiu Cristea
Browse files

ISAICP-7633: Fix for external URLs.

parent 94f79265
No related branches found
No related tags found
2 merge requests!89Release v1.90.3,!88ISAICP-7633: Allow ftp:// files as distribution remote URLs
......@@ -4,6 +4,7 @@
namespace Drupal\asset_distribution\Plugin\search_api\processor;
use Drupal\Component\Utility\UrlHelper;
use Drupal\Core\File\FileUrlGeneratorInterface;
use Drupal\search_api\IndexInterface;
use Drupal\search_api\Item\ItemInterface;
......@@ -127,7 +128,14 @@ protected function appendDistributionData(ItemInterface $item): void {
$distributionFieldItemList = $distribution->get('field_ad_access_url');
if (!$distributionFieldItemList->isEmpty()) {
foreach ($distributionFieldItemList->referencedEntities() as $file) {
$sapiField->addValue($this->fileUrlGenerator->generateAbsoluteString($file->getFileUri()));
$file_url = $file->getFileUri();
if (UrlHelper::isExternal($file_url) && !UrlHelper::externalIsLocal($file_url, $GLOBALS['base_url'])) {
$url = $file_url;
}
else {
$url = $this->fileUrlGenerator->generateAbsoluteString($file->getFileUri());
}
$sapiField->addValue($url);
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment