Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.
<?php

namespace MongoDB\GridFS\Exception;

use MongoDB\Exception\RuntimeException;
>
use function MongoDB\BSON\fromPHP; use function MongoDB\BSON\toJSON; use function sprintf; use function stream_get_meta_data; class StreamException extends RuntimeException { /** * @param resource $source * @param resource $destination */ public static function downloadFromFilenameFailed(string $filename, $source, $destination) : self { $sourceMetadata = stream_get_meta_data($source); $destinationMetadata = stream_get_meta_data($destination); return new static(sprintf('Downloading file from "%s" to "%s" failed. GridFS filename: "%s"', $sourceMetadata['uri'], $destinationMetadata['uri'], $filename)); } /** * @param mixed $id * @param resource $source * @param resource $destination */ public static function downloadFromIdFailed($id, $source, $destination) : self { $idString = toJSON(fromPHP(['_id' => $id])); $sourceMetadata = stream_get_meta_data($source); $destinationMetadata = stream_get_meta_data($destination); return new static(sprintf('Downloading file from "%s" to "%s" failed. GridFS identifier: "%s"', $sourceMetadata['uri'], $destinationMetadata['uri'], $idString)); } /** @param resource $source */ public static function uploadFailed(string $filename, $source, string $destinationUri) : self { $sourceMetadata = stream_get_meta_data($source); return new static(sprintf('Uploading file from "%s" to "%s" failed. GridFS filename: "%s"', $sourceMetadata['uri'], $destinationUri, $filename)); } }