Skip to content
Merged
Changes from 2 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 26 additions & 2 deletions administrator/components/com_media/src/Model/ApiModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
use Joomla\Component\Media\Administrator\Exception\FileNotFoundException;
use Joomla\Component\Media\Administrator\Exception\InvalidPathException;
use Joomla\Component\Media\Administrator\Provider\ProviderManager;
use Joomla\Event\Event;

/**
* Api Model
Expand Down Expand Up @@ -116,6 +117,11 @@ public function getFile($adapter, $path = '/', $options = [])
$file->path = $adapter . ":" . $file->path;
$file->adapter = $adapter;

Factory::getApplication()->getDispatcher()->dispatch(
'onFetchMediaFile',
new Event('onFetchMediaFile', [$file])
);

return $file;
}

Expand Down Expand Up @@ -178,8 +184,15 @@ public function getFiles($adapter, $path = '/', $options = [])
$file->adapter = $adapter;
}

$files = array_values($files);

Factory::getApplication()->getDispatcher()->dispatch(
'onFetchMediaFiles',
new Event('onFetchMediaFiles', [$files])
);

// Return array with proper indexes
return array_values($files);
return $files;
}

/**
Expand Down Expand Up @@ -454,7 +467,18 @@ public function getUrl($adapter, $path)
throw new InvalidPathException;
}

return $this->getAdapter($adapter)->getUrl($path);
$url = $this->getAdapter($adapter)->getUrl($path);
$newUrl = Factory::getApplication()->getDispatcher()->dispatch(
'onFetchMediaFileUrl',
new Event('onFetchMediaFileUrl', [$url])
);

if ($newUrl && $newUrl !== false)
{
$url = $newUrl;
}

return $url;
}

/**
Expand Down