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);
    }
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);
    }
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 ) ; }
Static helper method for directory listings.

@param \Twig_Environment $environment
@param string            $dir         Path to list
@param string            $current
@param string            $sortOrder
@param string            $sortBy
@param string            $filter
@param int               $limit

@return ArrayIterator

@throws \Twig_Error_Loader
@throws \Twig_Error_Runtime
@throws \Twig_Error_Syntax
Static helper method for directory listings .