protected function cleanDirectory(Finder $finder, OutputInterface $output)
    {
        $count = 0;
        $files = [];

        // Finder and Filesystem doen't really work well when we delete directories while we iterate through them.
        // That's why we iterate over all files and store the path in an array
        foreach ($finder as $file) {
            $files[] = $file->getPathname();
        }

        foreach ($files as $file) {
            if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) {
                $output->writeln(sprintf('Delete: <comment>%s</comment>', $file));
            }
            $this->filesystem->remove($file);
            $count += 1;
        }

        return $count;
    }
protected function cleanDirectory(Finder $finder, OutputInterface $output)
    {
        $count = 0;
        $files = [];

        // Finder and Filesystem doen't really work well when we delete directories while we iterate through them.
        // That's why we iterate over all files and store the path in an array
        foreach ($finder as $file) {
            $files[] = $file->getPathname();
        }

        foreach ($files as $file) {
            if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) {
                $output->writeln(sprintf('Delete: <comment>%s</comment>', $file));
            }
            $this->filesystem->remove($file);
            $count += 1;
        }

        return $count;
    }
protected function cleanDirectory ( Finder $ finder , OutputInterface $ output ) { $ count = 0 ; $ files = [ ] ; // Finder and Filesystem doen't really work well when we delete directories while we iterate through them. // That's why we iterate over all files and store the path in an array foreach ( $ finder as $ file ) { $ files [ ] = $ file -> getPathname ( ) ; } foreach ( $ files as $ file ) { if ( $ output -> getVerbosity ( ) >= OutputInterface :: VERBOSITY_VERBOSE ) { $ output -> writeln ( sprintf ( 'Delete: <comment>%s</comment>' , $ file ) ) ; } $ this -> filesystem -> remove ( $ file ) ; $ count += 1 ; } return $ count ; }
Iteratores over all given files and deletes them.

@param Finder          $finder
@param OutputInterface $output

@return integer Number of deleted files
Iteratores over all given files and deletes them .