Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.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)); } }