[Request] Add extra parameter to FileSystem->directories($directory,$depth)
Right now on the function you can give only the directory to search for. https://github.com/laravel/framework/blob/master/src/Illuminate/Filesystem/Filesystem.php#L276
But the symfony finder accepts a parameter for depth which is set to 0 https://github.com/laravel/framework/blob/master/src/Illuminate/Filesystem/Filesystem.php#L280
If we could do something like
$FileSystem->directories('/path/to/dir',2);
A use case would be to get all package directories in the vendor map.
Also an option to return the Symfony\Component\Finder\SplFileInfo object would be a great addition.
That way i get all the functions from the SplFileInfo.
$FileSystem->directories('/path/to/dir',true,2);
public function directories($directory,$spl=false,$depth=0)
{
$directories = array();
foreach (Finder::create()->in($directory)->directories()->depth($depth) as $dir)
{
$directories[] = $spl ? $dir : $dir->getPathname();
}
return $directories;
}
Use the Symfony Finder component. It should already be included in your Laravel install.
— Sent from Mailbox for iPhone
On Sun, Nov 10, 2013 at 7:52 AM, Marc van der Meulen [email protected] wrote:
Also an option to return the
Symfony\Component\Finder\SplFileInfoobject would be a great addition. That way i get all the functions from the SplFileInfo.$FileSystem->directories('/path/to/dir',true,2); public function directories($directory,$spl=false,$depth=0) { $directories = array(); foreach (Finder::create()->in($directory)->directories()->depth($depth) as $dir) { $directories[] = $spl ? $dir : $dir->getPathname(); } return $directories; }
Reply to this email directly or view it on GitHub: https://github.com/laravel/framework/issues/2686#issuecomment-28150955