Newscoop\Storage::listPaths PHP Method

listPaths() public method

public listPaths ( $dir )
    public function listPaths($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;
                    $items[] = substr($currentDir . "/" . $file, strlen($path));
                }
            }
        }
        return $items;
    }

Usage Example

コード例 #1
0
ファイル: Template.php プロジェクト: sourcefabric/newscoop
 /**
  * List paths in theme dir..
  * @param string $path
  */
 public function listPaths($path)
 {
     return $this->storage->listPaths($path);
 }