Banago\PHPloy\PHPloy::purge PHP Метод

purge() публичный Метод

Purge given directory's contents.
public purge ( $purgeDirs )
    public function purge($purgeDirs)
    {
        foreach ($purgeDirs as $dir) {
            $this->cli->out("<red>Purging directory <white>{$dir}");
            // Recursive file/dir listing
            $contents = $this->connection->listContents($dir, true);
            if (count($contents) < 1) {
                $this->cli->out(" - Nothing to purge in {$dir}");
                return;
            }
            $innerDirs = [];
            foreach ($contents as $item) {
                if ($item['type'] === 'file') {
                    $this->connection->delete($item['path']);
                    $this->cli->out("<red> × {$item['path']} is removed from directory");
                } elseif ($item['type'] === 'dir') {
                    // Directories need to be stacked to be
                    // deleted at the end when they are empty
                    $innerDirs[] = $item['path'];
                }
            }
            if (count($innerDirs) > 0) {
                foreach ($innerDirs as $innerDir) {
                    $this->connection->deleteDir($innerDir);
                    $this->cli->out("<red> ×  {$innerDir} directory");
                }
            }
            $this->cli->out("<red>Purged <white>{$dir}");
        }
    }