Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. StreamWrapper.php

function StreamWrapper::getResource

Returns a resource representing the stream.

Parameters

StreamInterface $stream The stream to get a resource for:

Return value

resource

Throws

\InvalidArgumentException if stream is not readable or writable

1 call to StreamWrapper::getResource()
InflateStream::__construct in vendor/guzzlehttp/psr7/src/InflateStream.php

File

vendor/guzzlehttp/psr7/src/StreamWrapper.php, line 34

Class

StreamWrapper
Converts Guzzle streams into PHP stream resources.

Namespace

GuzzleHttp\Psr7

Code

public static function getResource(StreamInterface $stream) {
    self::register();
    if ($stream->isReadable()) {
        $mode = $stream->isWritable() ? 'r+' : 'r';
    }
    elseif ($stream->isWritable()) {
        $mode = 'w';
    }
    else {
        throw new \InvalidArgumentException('The stream must be readable, ' . 'writable, or both.');
    }
    return fopen('guzzle://stream', $mode, false, self::createStreamContext($stream));
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal