src/Gzero/Cms/BlockFinder.php
protected function findBlocksForPath($routable, $filter)
    {
        if (is_string($routable)) { // static page like "home", "contact" etc.
            return $this->handleStaticPageCase($routable, $filter);
        }
        $ids      = $routable->getTreePath();
        $idsCount = count($ids);
        $blockIds = [];
        if ($idsCount === 1) { // Root case
            $allIds   = [];
            $rootPath = $ids[0] . '/';
            if (isset($filter['paths'][$rootPath])) {
                $allIds = $filter['paths'][$rootPath];
            }
            // We're returning only blocks ids that uses filter property
            $blockIds = array_keys($allIds + $filter['excluded'], true, true);
        } else {
            $allIds     = [];
            $parentPath = '';
            foreach ($ids as $index => $id) {
                $parentPath .= $id . '/';
                $pathMatch  = ($index + 1 < $idsCount) ? $parentPath . '*' : $parentPath;
                if (isset($filter['paths'][$pathMatch])) {
                    // Order of operation is important! We want to override $allIds be lower level filter (left overrides right)
                    $allIds = $filter['paths'][$pathMatch] + $allIds;
                }
            }
            // We're returning only blocks ids that uses filter property
            $blockIds = array_keys($allIds + $filter['excluded'], true, true);
        }
        return $blockIds;
    }
protected function findBlocksForPath($routable, $filter)
    {
        if (is_string($routable)) { // static page like "home", "contact" etc.
            return $this->handleStaticPageCase($routable, $filter);
        }
        $ids      = $routable->getTreePath();
        $idsCount = count($ids);
        $blockIds = [];
        if ($idsCount === 1) { // Root case
            $allIds   = [];
            $rootPath = $ids[0] . '/';
            if (isset($filter['paths'][$rootPath])) {
                $allIds = $filter['paths'][$rootPath];
            }
            // We're returning only blocks ids that uses filter property
            $blockIds = array_keys($allIds + $filter['excluded'], true, true);
        } else {
            $allIds     = [];
            $parentPath = '';
            foreach ($ids as $index => $id) {
                $parentPath .= $id . '/';
                $pathMatch  = ($index + 1 < $idsCount) ? $parentPath . '*' : $parentPath;
                if (isset($filter['paths'][$pathMatch])) {
                    // Order of operation is important! We want to override $allIds be lower level filter (left overrides right)
                    $allIds = $filter['paths'][$pathMatch] + $allIds;
                }
            }
            // We're returning only blocks ids that uses filter property
            $blockIds = array_keys($allIds + $filter['excluded'], true, true);
        }
        return $blockIds;
    }
protected function findBlocksForPath ( $ routable , $ filter ) { if ( is_string ( $ routable ) ) { // static page like "home", "contact" etc. return $ this -> handleStaticPageCase ( $ routable , $ filter ) ; } $ ids = $ routable -> getTreePath ( ) ; $ idsCount = count ( $ ids ) ; $ blockIds = [ ] ; if ( $ idsCount === 1 ) { // Root case $ allIds = [ ] ; $ rootPath = $ ids [ 0 ] . '/' ; if ( isset ( $ filter [ 'paths' ] [ $ rootPath ] ) ) { $ allIds = $ filter [ 'paths' ] [ $ rootPath ] ; } // We're returning only blocks ids that uses filter property $ blockIds = array_keys ( $ allIds + $ filter [ 'excluded' ] , true , true ) ; } else { $ allIds = [ ] ; $ parentPath = '' ; foreach ( $ ids as $ index => $ id ) { $ parentPath .= $ id . '/' ; $ pathMatch = ( $ index + 1 < $ idsCount ) ? $ parentPath . '*' : $ parentPath ; if ( isset ( $ filter [ 'paths' ] [ $ pathMatch ] ) ) { // Order of operation is important! We want to override $allIds be lower level filter (left overrides right) $ allIds = $ filter [ 'paths' ] [ $ pathMatch ] + $ allIds ; } } // We're returning only blocks ids that uses filter property $ blockIds = array_keys ( $ allIds + $ filter [ 'excluded' ] , true , true ) ; } return $ blockIds ; }
Find all blocks ids that should be displayed on specific path

@param string|Routable $routable Routable path or static page named route
@param array           $filter   Array with all filters

@return array
Find all blocks ids that should be displayed on specific path