public function loadPages($request)
    {
        $pageMapper = ($this->dataMapper)('pageMapper');

        // Fetch all published pages
        $this->pages = $pageMapper->findPages();

        // Set flag on page for current request
        $url = $request->getUri()->getPath();
        // Check if home page '/' to match slug name
        $url = ($url === '/') ? 'home' : ltrim($url, '/');
        $key = array_search($url, array_column($this->pages, 'slug'));

        if (is_numeric($key)) {
            $this->pages[$key]->currentPage = true;
        }

        return;
    }
public function loadPages($request)
    {
        $pageMapper = ($this->dataMapper)('pageMapper');

        // Fetch all published pages
        $this->pages = $pageMapper->findPages();

        // Set flag on page for current request
        $url = $request->getUri()->getPath();
        // Check if home page '/' to match slug name
        $url = ($url === '/') ? 'home' : ltrim($url, '/');
        $key = array_search($url, array_column($this->pages, 'slug'));

        if (is_numeric($key)) {
            $this->pages[$key]->currentPage = true;
        }

        return;
    }
public function loadPages ( $ request ) { $ pageMapper = ( $ this -> dataMapper ) ( 'pageMapper' ) ; // Fetch all published pages $ this -> pages = $ pageMapper -> findPages ( ) ; // Set flag on page for current request $ url = $ request -> getUri ( ) -> getPath ( ) ; // Check if home page '/' to match slug name $ url = ( $ url === '/' ) ? 'home' : ltrim ( $ url , '/' ) ; $ key = array_search ( $ url , array_column ( $ this -> pages , 'slug' ) ) ; if ( is_numeric ( $ key ) ) { $ this -> pages [ $ key ] -> currentPage = true ; } return ; }
Load pages from DB

Sets currentPage = true flag on page record for current request
@param  \Psr\Http\Message\ServerRequestInterface $request  PSR7 request
@return void
Load pages from DB