Interfaces
2 weeks ago
trait-bufferedwritestreamviaputcontents.php
2 weeks ago
trait-copydirectoryrecursive.php
2 weeks ago
trait-copyfileviastreaming.php
2 weeks ago
trait-copyrecursiveviastreaming.php
2 weeks ago
trait-getcontentsviareadstream.php
2 weeks ago
trait-internalizewritestream.php
2 weeks ago
trait-mkdirrecursive.php
2 weeks ago
trait-putcontentsviawritestream.php
2 weeks ago
trait-readonlyfilesystem.php
2 weeks ago
trait-renamefileviacopyandrm.php
2 weeks ago
trait-rmdirrecursive.php
2 weeks ago
trait-readonlyfilesystem.php
58 lines
| 1 | <?php |
| 2 | |
| 3 | namespace WordPress\Filesystem\Mixin; |
| 4 | |
| 5 | use WordPress\ByteStream\WriteStream\ByteWriteStream; |
| 6 | use WordPress\Filesystem\FilesystemException; |
| 7 | |
| 8 | trait ReadOnlyFilesystem { |
| 9 | |
| 10 | public function mkdir( $path, $options = array() ) { |
| 11 | throw new FilesystemException( |
| 12 | sprintf( 'Cannot create directory: %s', $path ) |
| 13 | ); |
| 14 | } |
| 15 | |
| 16 | public function rm( $path, $options = array() ) { |
| 17 | throw new FilesystemException( |
| 18 | sprintf( 'Cannot remove file: %s', $path ) |
| 19 | ); |
| 20 | } |
| 21 | |
| 22 | public function rmdir( $path, $options = array() ) { |
| 23 | throw new FilesystemException( |
| 24 | sprintf( 'Cannot remove directory: %s', $path ) |
| 25 | ); |
| 26 | } |
| 27 | |
| 28 | public function put_contents( $path, $contents, $options = array() ) { |
| 29 | throw new FilesystemException( |
| 30 | sprintf( 'Cannot write to file: %s', $path ) |
| 31 | ); |
| 32 | } |
| 33 | |
| 34 | public function rename( $old_path, $new_path, $options = array() ) { |
| 35 | throw new FilesystemException( |
| 36 | sprintf( 'Cannot rename file: %s to %s', $old_path, $new_path ) |
| 37 | ); |
| 38 | } |
| 39 | |
| 40 | public function delete( $path, $options = array() ) { |
| 41 | throw new FilesystemException( |
| 42 | sprintf( 'Cannot delete file: %s', $path ) |
| 43 | ); |
| 44 | } |
| 45 | |
| 46 | public function copy( $source_path, $destination_path, $options = array() ) { |
| 47 | throw new FilesystemException( |
| 48 | sprintf( 'Cannot copy file: %s to %s', $source_path, $destination_path ) |
| 49 | ); |
| 50 | } |
| 51 | |
| 52 | public function open_write_stream( $path ): ByteWriteStream { |
| 53 | throw new FilesystemException( |
| 54 | sprintf( 'Cannot open write stream: %s', $path ) |
| 55 | ); |
| 56 | } |
| 57 | } |
| 58 |