VendorStreamWrapperService.php in Vendor Stream Wrapper 8
File
src/Service/VendorStreamWrapperService.php
View source
<?php
namespace Drupal\vendor_stream_wrapper\Service;
use Drupal\Core\StreamWrapper\StreamWrapperManagerInterface;
class VendorStreamWrapperService implements VendorStreamWrapperServiceInterface {
protected $streamWrapperService;
public function __construct(StreamWrapperManagerInterface $streamWrapperManager) {
$this->streamWrapperService = $streamWrapperManager;
}
public function creatUrlFromUri($uri) {
if (strpos($uri, 'vendor://') === 0) {
if ($wrapper = $this->streamWrapperService
->getViaUri($uri)) {
return $wrapper
->getExternalUrl()
->toString();
}
}
else {
return $uri;
}
}
}