ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\Filesystem\Stream\Streams Class Reference

Stream factory which enables the user to create streams without the knowledge of the concrete class. More...

+ Collaboration diagram for ILIAS\Filesystem\Stream\Streams:

Static Public Member Functions

static ofString (string $string)
 Creates a new stream with an initial value. More...
 
static ofResource ($resource)
 Wraps an already created resource with the stream abstraction. More...
 
static ofReattachableResource ($resource)
 
static ofFileInsideZIP (string $path_to_zip, string $path_inside_zip)
 
static ofPsr7Stream (StreamInterface $stream)
 Create a FileStream from a Psr7 compliant stream. More...
 

Detailed Description

Stream factory which enables the user to create streams without the knowledge of the concrete class.

Author
Nicolas Schäfli ns@st.nosp@m.uder.nosp@m.-raim.nosp@m.ann..nosp@m.ch
Fabian Schmid fabia.nosp@m.n@sr.nosp@m..solu.nosp@m.tion.nosp@m.s

Definition at line 31 of file Streams.php.

Member Function Documentation

◆ ofFileInsideZIP()

static ILIAS\Filesystem\Stream\Streams::ofFileInsideZIP ( string  $path_to_zip,
string  $path_inside_zip 
)
static

Definition at line 84 of file Streams.php.

84 : ZIPStream
85 {
86 // we try to open the zip file with the path inside the zip file, once with a leading slash and once without
87 try {
88 $resource = fopen('zip://' . $path_to_zip . '#/' . $path_inside_zip, 'rb');
89 } catch (\Throwable) {
90 $resource = null;
91 }
92 try {
93 $resource = $resource ?: fopen('zip://' . $path_to_zip . '#' . $path_inside_zip, 'rb');
94 } catch (\Throwable) {
95 $resource = null;
96 }
97
98 if (!is_resource($resource)) {
99 throw new \InvalidArgumentException(
100 'The argument $path_to_zip must be an existing zip file path and $path_inside_zip must be a valid path inside the zip file.'
101 );
102 }
103 return new ZIPStream($resource);
104 }

Referenced by ILIAS\components\ResourceStorage\Container\Wrapper\ZipReader\getItem().

+ Here is the caller graph for this function:

◆ ofPsr7Stream()

static ILIAS\Filesystem\Stream\Streams::ofPsr7Stream ( StreamInterface  $stream)
static

Create a FileStream from a Psr7 compliant stream.

Please not that the stream must be detached from the psr7 stream in order to create the filesystem stream.

Parameters
StreamInterface$streamThe stream which should be parsed into a FileStream.
Returns
FileStream The newly created stream.

Definition at line 113 of file Streams.php.

113 : Stream
114 {
115 $resource = $stream->detach();
116 return self::ofResource($resource);
117 }
static ofResource($resource)
Wraps an already created resource with the stream abstraction.
Definition: Streams.php:64

References ILIAS\Filesystem\Stream\Stream\detach(), and ILIAS\Filesystem\Stream\Streams\ofResource().

Referenced by ILIAS\FileUpload\FileUploadImpl\moveFilesTo(), ILIAS\FileUpload\FileUploadImpl\moveOneFileTo(), and ILIAS\FileUpload\FileUploadImpl\process().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ofReattachableResource()

static ILIAS\Filesystem\Stream\Streams::ofReattachableResource (   $resource)
static

Definition at line 74 of file Streams.php.

74 : ReattachableStream
75 {
76 if (!is_resource($resource)) {
77 throw new \InvalidArgumentException(
78 'The argument $resource must be of type resource but was "' . gettype($resource) . '"'
79 );
80 }
81 return new ReattachableStream($resource);
82 }

◆ ofResource()

static ILIAS\Filesystem\Stream\Streams::ofResource (   $resource)
static

Wraps an already created resource with the stream abstraction.

The stream abstraction only supports streams which are opened with fopen.

Parameters
resource$resourceThe resource which should be wrapped.
Returns
FileStream The newly created stream which wraps the given resource.
See also
fopen()

Definition at line 64 of file Streams.php.

64 : Stream
65 {
66 if (!is_resource($resource)) {
67 throw new \InvalidArgumentException(
68 'The argument $resource must be of type resource but was "' . gettype($resource) . '"'
69 );
70 }
71 return new Stream($resource);
72 }

Referenced by ILIAS\Filesystem\Util\Archive\Zip\addPath(), ILIAS\Filesystem\Util\Convert\ImageConverter\buildOutputStream(), ILIAS\Filesystem\Util\Archive\Zip\get(), ILIAS\Filesystem\Util\ZipTest\LegacyZipWithTop(), ILIAS\Filesystem\Stream\Streams\ofPsr7Stream(), ilDclFileRecordFieldModel\parseValue(), ILIAS\Filesystem\Util\Archive\Unzip\pathToStreamGenerator(), ILIAS\Filesystem\Provider\FlySystem\FlySystemFileStreamAccess\readStream(), ILIAS\ResourceStorage\Consumer\DownloadMultipleConsumer\run(), ILIAS\Test\ResponseHandler\sendAsync(), ILIAS\Filesystem\Util\ImageConversionTest\testImageSquareActualImage(), ILIAS\Filesystem\Util\ImageConversionTest\testImageThumbnailActualImage(), ILIAS\Filesystem\Util\ZipTest\testLegacyZip(), ILIAS\Filesystem\Util\UnzipTest\testWrongZip(), ILIAS\Filesystem\Util\ZipTest\testWrongZip(), ILIAS\Filesystem\Util\ZipTest\testZip(), and ILIAS\Repository\Resources\ZipAdapter\unzipFile().

+ Here is the caller graph for this function:

◆ ofString()

static ILIAS\Filesystem\Stream\Streams::ofString ( string  $string)
static

Creates a new stream with an initial value.

Please note that the whole stream is stored within memory.

Parameters
string$stringThe string which should be written as initial value.
Returns
FileStream The newly created in memory stream.

Definition at line 41 of file Streams.php.

41 : Stream
42 {
43 if (!is_string($string)) {
44 throw new \InvalidArgumentException(
45 'The argument $string must be of type string but was "' . gettype($string) . '"'
46 );
47 }
48
49 $stream = new Stream(fopen('php://memory', 'rw'));
50 $stream->write($string);
51 return $stream;
52 }

Referenced by ILIAS\User\Profile\Fields\ConfigurationGUI\actionCmd(), ILIAS\User\Settings\ConfigurationGUI\actionCmd(), ILIAS\UI\examples\Input\Field\TreeMultiSelect\base(), ILIAS\UI\examples\Input\Field\TreeSelect\base(), ILIAS\Filesystem\Util\Convert\ImageConverter\buildOutputStream(), ILIAS\UI\examples\Progress\Bar\callArtificialTaskEndpoint(), ilPropertyFormGUI\checkInput(), ILIAS\FileUpload\Handler\AbstractCtrlAwareUploadHandler\executeCommand(), ILIAS\LegalDocuments\Administration\exitWithJsonResponse(), ilECSSettingsGUI\exportImported(), ilECSSettingsGUI\exportReleased(), ILIAS\Test\Scoring\Manual\TestScoringByQuestionGUI\getAnswerDetail(), ILIAS\ResourceStorage\AbstractTestBase\getDummyStream(), ILIAS\WOPI\Handler\RequestHandler\handleRequest(), ILIAS\GlobalScreen\Client\Notifications\handleRerender(), ILIAS\ResourceStorage\Flavour\Machine\DefaultMachines\CropSquare\maybeRotate(), ilDataCollectionGlobalTemplate\printToStdout(), ILIAS\COPage\Editor\Server\Response\send(), ILIAS\Export\PrintProcessGUI\send(), ILIAS\Repository\send(), ILIAS\Test\ResponseHandler\sendAsync(), ILIAS\MetaData\OERExposer\OAIPMH\HTTP\Wrapper\sendResponseAndClose(), ILIAS\Repository\HTTP\HTTPUtil\sendString(), ILIAS\Saml\Module\sendXMLString(), ILIAS\Filesystem\Util\ZipTest\testLargeZIPs(), ILIAS\ResourceStorage\Flavours\FlavourMachineTest\testMachineResult(), ILIAS\FileUpload\Processor\SVGPreProcessorTest\testMaliciousSVG(), ILIAS\ResourceStorage\Flavours\FlavourTest\testNewFlavour(), ILIAS\VirusScanner\tests\VirusScannerPreProcessorTest\testNoVirusDetected(), ILIAS\FileUpload\FileUploadImplTest\testProcessWhichShouldSucceed(), ILIAS\FileUpload\Processor\BlacklistExtensionPreProcessorTest\testProcessWhichShouldSucceed(), ILIAS\FileUpload\Processor\BlacklistFileHeaderPreProcessorTest\testProcessWhichShouldSucceed(), ILIAS\FileUpload\Processor\FilenameOverridePreProcessorTest\testProcessWhichShouldSucceed(), ILIAS\FileUpload\Processor\WhitelistExtensionPreProcessorTest\testProcessWhichShouldSucceed(), ILIAS\FileUpload\Processor\WhitelistFileHeaderPreProcessorTest\testProcessWhichShouldSucceed(), ILIAS\FileUpload\Processor\BlacklistExtensionPreProcessorTest\testProcessWithBlacklistedEmptyExtensionWhichShouldGetRejected(), ILIAS\FileUpload\Processor\BlacklistExtensionPreProcessorTest\testProcessWithBlacklistedExtensionWhichShouldGetRejected(), ILIAS\FileUpload\FileUploadImplTest\testProcessWithFailedUploadWhichShouldGetRejected(), ILIAS\FileUpload\Processor\BlacklistFileHeaderPreProcessorTest\testProcessWithHeaderMismatchWhichShouldGetRejected(), ILIAS\FileUpload\Processor\WhitelistFileHeaderPreProcessorTest\testProcessWithHeaderMismatchWhichShouldGetRejected(), ILIAS\FileUpload\Processor\WhitelistExtensionPreProcessorTest\testProcessWithoutExtensionWhichShouldSucceed(), ILIAS\FileUpload\Processor\WhitelistExtensionPreProcessorTest\testProcessWithoutWhitelistedExtensionWhichShouldGetRejected(), Filesystem\Provider\FlySystem\FlySystemFileStreamAccessTest\testPutStreamWhichShouldSucceed(), Filesystem\Provider\FlySystem\FlySystemFileStreamAccessTest\testPutStreamWithDetachedStreamWhichShouldFail(), Filesystem\Provider\FlySystem\FlySystemFileStreamAccessTest\testPutStreamWithGeneralFailureWhichShouldFail(), ILIAS\FileUpload\Processor\SVGPreProcessorTest\testSaneSVG(), ILIAS\FileUpload\Processor\SVGPreProcessorTest\testSomeComplexSaneSVG(), Filesystem\Provider\FlySystem\FlySystemFileStreamAccessTest\testUpdateStreamWhichShouldSucceed(), Filesystem\Provider\FlySystem\FlySystemFileStreamAccessTest\testUpdateStreamWithDetachedStreamWhichShouldFail(), Filesystem\Provider\FlySystem\FlySystemFileStreamAccessTest\testUpdateStreamWithGeneralFailureWhichShouldFail(), Filesystem\Provider\FlySystem\FlySystemFileStreamAccessTest\testUpdateStreamWithMissingFileWhichShouldFail(), ILIAS\VirusScanner\tests\VirusScannerPreProcessorTest\testVirusDetected(), Filesystem\Provider\FlySystem\FlySystemFileStreamAccessTest\testWriteStreamWhichShouldSucceed(), Filesystem\Provider\FlySystem\FlySystemFileStreamAccessTest\testWriteStreamWithDetachedStreamWhichShouldFail(), Filesystem\Provider\FlySystem\FlySystemFileStreamAccessTest\testWriteStreamWithExistingFileWhichShouldFail(), Filesystem\Provider\FlySystem\FlySystemFileStreamAccessTest\testWriteStreamWithFailingAdapterWhichShouldFail(), ILIAS\ResourceStorage\Flavour\Machine\DefaultMachines\to(), ILIAS\Export\ExportHandler\Manager\Handler\writeToElement(), and ILIAS\Filesystem\Util\Archive\Archives\zip().

+ Here is the caller graph for this function:

The documentation for this class was generated from the following file: