protected function _filterBlock(Block $block)
    {
        $cacheKey = "allowed_{$block->id}";
        $cache = static::cache($cacheKey);

        if ($cache !== null) {
            return $cache;
        }

        if (!empty($block->locale) &&
            !in_array(I18n::locale(), (array)$block->locale)
        ) {
            return static::cache($cacheKey, false);
        }

        if (!$block->isAccessibleByUser()) {
            return static::cache($cacheKey, false);
        }

        $allowed = false;
        switch ($block->visibility) {
            case 'except':
                // Show on all pages except listed pages
                $allowed = !$this->_urlMatch($block->pages);
                break;
            case 'only':
                // Show only on listed pages
                $allowed = $this->_urlMatch($block->pages);
                break;
            case 'php':
                // Use custom PHP code to determine visibility
                $allowed = php_eval($block->pages, [
                    'view' => &$this->_View,
                    'block' => &$block
                ]) === true;
                break;
        }

        if (!$allowed) {
            return static::cache($cacheKey, false);
        }

        return static::cache($cacheKey, true);
    }
protected function _filterBlock(Block $block)
    {
        $cacheKey = "allowed_{$block->id}";
        $cache = static::cache($cacheKey);

        if ($cache !== null) {
            return $cache;
        }

        if (!empty($block->locale) &&
            !in_array(I18n::locale(), (array)$block->locale)
        ) {
            return static::cache($cacheKey, false);
        }

        if (!$block->isAccessibleByUser()) {
            return static::cache($cacheKey, false);
        }

        $allowed = false;
        switch ($block->visibility) {
            case 'except':
                // Show on all pages except listed pages
                $allowed = !$this->_urlMatch($block->pages);
                break;
            case 'only':
                // Show only on listed pages
                $allowed = $this->_urlMatch($block->pages);
                break;
            case 'php':
                // Use custom PHP code to determine visibility
                $allowed = php_eval($block->pages, [
                    'view' => &$this->_View,
                    'block' => &$block
                ]) === true;
                break;
        }

        if (!$allowed) {
            return static::cache($cacheKey, false);
        }

        return static::cache($cacheKey, true);
    }
protected function _filterBlock ( Block $ block ) { $ cacheKey = "allowed_{$block->id}" ; $ cache = static :: cache ( $ cacheKey ) ; if ( $ cache !== null ) { return $ cache ; } if ( ! empty ( $ block -> locale ) && ! in_array ( I18n :: locale ( ) , ( array ) $ block -> locale ) ) { return static :: cache ( $ cacheKey , false ) ; } if ( ! $ block -> isAccessibleByUser ( ) ) { return static :: cache ( $ cacheKey , false ) ; } $ allowed = false ; switch ( $ block -> visibility ) { case 'except' : // Show on all pages except listed pages $ allowed = ! $ this -> _urlMatch ( $ block -> pages ) ; break ; case 'only' : // Show only on listed pages $ allowed = $ this -> _urlMatch ( $ block -> pages ) ; break ; case 'php' : // Use custom PHP code to determine visibility $ allowed = php_eval ( $ block -> pages , [ 'view' => & $ this -> _View , 'block' => & $ block ] ) === true ; break ; } if ( ! $ allowed ) { return static :: cache ( $ cacheKey , false ) ; } return static :: cache ( $ cacheKey , true ) ; }
Checks if the given block can be rendered.

@param \Block\Model\Entity\Block $block Block entity
@return bool True if can be rendered
Checks if the given block can be rendered .