src/Charcoal/Cms/Service/Manager/NewsManager.php
public function setPrevNext()
    {
        if ($this->nextNews && $this->prevNews) {
            return $this;
        }
        $entries = $this->entries();

        $isPrev = false;
        $isNext = false;
        $firstNews = false;
        $lastNews = false;

        /** @var NewsInterface $news */
        foreach ($entries as $news) {
            // Obtain th first news.
            if (!$firstNews) {
                $firstNews = $news;
            }
            $lastNews = $news;
            // Find the current news
            if ($news->id() == $this->currentNews()['id']) {
                $isNext = true;
                $isPrev = true;

                continue;
            }
            if (!$isPrev) {
                $this->prevNews = $news;
            }
            // Store the next news
            if ($isNext) {
                $this->nextNews = $news;

                $isNext = false;
            }
        }

        if ($this->entryCycle()) {
            if (!$this->nextNews) {
                $this->nextNews = $firstNews;
            }

            if (!$this->prevNews) {
                $this->prevNews = $lastNews;
            }
        }

        return $this;
    }
public function setPrevNext()
    {
        if ($this->nextNews && $this->prevNews) {
            return $this;
        }
        $entries = $this->entries();

        $isPrev = false;
        $isNext = false;
        $firstNews = false;
        $lastNews = false;

        /** @var NewsInterface $news */
        foreach ($entries as $news) {
            // Obtain th first news.
            if (!$firstNews) {
                $firstNews = $news;
            }
            $lastNews = $news;
            // Find the current news
            if ($news->id() == $this->currentNews()['id']) {
                $isNext = true;
                $isPrev = true;

                continue;
            }
            if (!$isPrev) {
                $this->prevNews = $news;
            }
            // Store the next news
            if ($isNext) {
                $this->nextNews = $news;

                $isNext = false;
            }
        }

        if ($this->entryCycle()) {
            if (!$this->nextNews) {
                $this->nextNews = $firstNews;
            }

            if (!$this->prevNews) {
                $this->prevNews = $lastNews;
            }
        }

        return $this;
    }
public function setPrevNext ( ) { if ( $ this -> nextNews && $ this -> prevNews ) { return $ this ; } $ entries = $ this -> entries ( ) ; $ isPrev = false ; $ isNext = false ; $ firstNews = false ; $ lastNews = false ; /** @var NewsInterface $news */ foreach ( $ entries as $ news ) { // Obtain th first news. if ( ! $ firstNews ) { $ firstNews = $ news ; } $ lastNews = $ news ; // Find the current news if ( $ news -> id ( ) == $ this -> currentNews ( ) [ 'id' ] ) { $ isNext = true ; $ isPrev = true ; continue ; } if ( ! $ isPrev ) { $ this -> prevNews = $ news ; } // Store the next news if ( $ isNext ) { $ this -> nextNews = $ news ; $ isNext = false ; } } if ( $ this -> entryCycle ( ) ) { if ( ! $ this -> nextNews ) { $ this -> nextNews = $ firstNews ; } if ( ! $ this -> prevNews ) { $ this -> prevNews = $ lastNews ; } } return $ this ; }
Set the Prev and Next news
@return $this
Set the Prev and Next news