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-rmdirrecursive.php
26 lines
| 1 | <?php |
| 2 | |
| 3 | namespace WordPress\Filesystem\Mixin; |
| 4 | |
| 5 | use function WordPress\Filesystem\wp_join_unix_paths; |
| 6 | |
| 7 | trait RmdirRecursive { |
| 8 | |
| 9 | public function rmdir( $path, $options = array() ) { |
| 10 | $recursive = $options['recursive'] ?? false; |
| 11 | if ( $recursive ) { |
| 12 | foreach ( $this->ls( $path ) as $child ) { |
| 13 | $child_path = wp_join_unix_paths( $path, $child ); |
| 14 | if ( $this->is_dir( $child_path ) ) { |
| 15 | $this->rmdir( $child_path, $options ); |
| 16 | } else { |
| 17 | $this->rm( $child_path ); |
| 18 | } |
| 19 | } |
| 20 | } |
| 21 | $this->rmdir_single( $path, $options ); |
| 22 | } |
| 23 | |
| 24 | abstract protected function rmdir_single( $path, $options = array() ); |
| 25 | } |
| 26 |