Newscoop\Storage::nrListItems PHP Method

nrListItems() public method

public nrListItems ( $dir )
    public function nrListItems($dir)
    {
        $items = array();
        $path = $this->getPath($dir, TRUE);
        if (!$path) {
            throw new \InvalidArgumentException($dir, self::ERROR_NOT_FOUND);
        }
        $scanDirs = array($path);
        for ($i = 0;; $i++) {
            // break if stack finished
            if (!isset($scanDirs[$i])) {
                break;
            }
            $currentDir = $scanDirs[$i];
            foreach (array_diff(scandir($currentDir), array(".", "..")) as $file) {
                // add directory to stack
                if (is_dir($currentDir . "/" . $file)) {
                    $scanDirs[] = $currentDir . "/" . $file;
                } else {
                    $items[] = basename($file);
                }
            }
        }
        return $items;
    }