You are here

class VendorStreamWrapperService in Vendor Stream Wrapper 8

Provides services for the Vendor Stream Wrapper module.

Hierarchy

Expanded class hierarchy of VendorStreamWrapperService

1 string reference to 'VendorStreamWrapperService'
vendor_stream_wrapper.services.yml in ./vendor_stream_wrapper.services.yml
vendor_stream_wrapper.services.yml
1 service uses VendorStreamWrapperService
vendor_stream_wrapper.service in ./vendor_stream_wrapper.services.yml
Drupal\vendor_stream_wrapper\Service\VendorStreamWrapperService

File

src/Service/VendorStreamWrapperService.php, line 10

Namespace

Drupal\vendor_stream_wrapper\Service
View source
class VendorStreamWrapperService implements VendorStreamWrapperServiceInterface {

  /**
   * The Stream Wrapper Service.
   *
   * @var Drupal\Core\StreamWrapper\StreamWrapperManagerInterface
   */
  protected $streamWrapperService;

  /**
   * Constructor.
   */
  public function __construct(StreamWrapperManagerInterface $streamWrapperManager) {
    $this->streamWrapperService = $streamWrapperManager;
  }

  /**
   * {@inheritdoc}
   */
  public function creatUrlFromUri($uri) {
    if (strpos($uri, 'vendor://') === 0) {
      if ($wrapper = $this->streamWrapperService
        ->getViaUri($uri)) {
        return $wrapper
          ->getExternalUrl()
          ->toString();
      }
    }
    else {
      return $uri;
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
VendorStreamWrapperService::$streamWrapperService protected property The Stream Wrapper Service.
VendorStreamWrapperService::creatUrlFromUri public function Creates a public facing URL from URIs with the vendor:// schema. Overrides VendorStreamWrapperServiceInterface::creatUrlFromUri
VendorStreamWrapperService::__construct public function Constructor.