ListPaths.php 672 B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. namespace League\Flysystem\Plugin;
  3. class ListPaths extends AbstractPlugin
  4. {
  5. /**
  6. * Get the method name.
  7. *
  8. * @return string
  9. */
  10. public function getMethod()
  11. {
  12. return 'listPaths';
  13. }
  14. /**
  15. * List all paths.
  16. *
  17. * @param string $directory
  18. * @param bool $recursive
  19. *
  20. * @return string[] paths
  21. */
  22. public function handle($directory = '', $recursive = false)
  23. {
  24. $result = [];
  25. $contents = $this->filesystem->listContents($directory, $recursive);
  26. foreach ($contents as $object) {
  27. $result[] = $object['path'];
  28. }
  29. return $result;
  30. }
  31. }