public static function dir(\Twig_Environment $environment, $dir, $current, $sortOrder = null, $sortBy = 'link', $filter = null, $limit = null, $userAgentEnabled = false)
    {
        $pagelist = [];

        // create new instance
        $iterator = new \RecursiveIteratorIterator(
            new \RecursiveDirectoryIterator($dir),
            \RecursiveIteratorIterator::SELF_FIRST
        );

        foreach ($iterator as $item) {
            if (!strpos(str_replace('\\', '/', $item->getPathname()), $current) && $item->isFile()) {
                $fullPath = $item->getPathname();
                $relativePath = Page::generateRelativePath($fullPath);
                $template = $environment->load($relativePath);
                $page = new Page($template, [], $userAgentEnabled);
                $pagelist[] = $page;
            }
        }

        // apply filter
//        $pagelist = self::applyFilter( $pagelist, $filter );

        // apply sorting
        $pagelist = self::applySorting($pagelist, $sortOrder, $sortBy);

        // apply limit
        $pagelist = self::applyLimit($pagelist, $limit);

        return new ArrayIterator($pagelist);
    }