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

        $isPrev = false;
        $isNext = false;
        $firstEvent = false;
        $lastEvent = false;

        foreach ($entries as $event) {
            // Obtain th first event.
            if (!$firstEvent) {
                $firstEvent = $event;
            }
            $lastEvent = $event;
            // Find the current event
            if ($event->id() == $this->currentEvent()['id']) {
                $isNext = true;
                $isPrev = true;

                continue;
            }
            if (!$isPrev) {
                $this->prevEvent = $event;
            }
            // Store the next event
            if ($isNext) {
                $this->nextEvent = $event;

                $isNext = false;
            }
        }

        if ($this->entryCycle()) {
            if (!$this->nextEvent) {
                $this->nextEvent = $firstEvent;
            }

            if (!$this->prevEvent) {
                $this->prevEvent = $lastEvent;
            }
        }

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

        $isPrev = false;
        $isNext = false;
        $firstEvent = false;
        $lastEvent = false;

        foreach ($entries as $event) {
            // Obtain th first event.
            if (!$firstEvent) {
                $firstEvent = $event;
            }
            $lastEvent = $event;
            // Find the current event
            if ($event->id() == $this->currentEvent()['id']) {
                $isNext = true;
                $isPrev = true;

                continue;
            }
            if (!$isPrev) {
                $this->prevEvent = $event;
            }
            // Store the next event
            if ($isNext) {
                $this->nextEvent = $event;

                $isNext = false;
            }
        }

        if ($this->entryCycle()) {
            if (!$this->nextEvent) {
                $this->nextEvent = $firstEvent;
            }

            if (!$this->prevEvent) {
                $this->prevEvent = $lastEvent;
            }
        }

        return $this;
    }
public function setPrevNext ( ) { if ( $ this -> prevEvent && $ this -> nextEvent ) { return $ this ; } $ entries = $ this -> entries ( ) ; $ isPrev = false ; $ isNext = false ; $ firstEvent = false ; $ lastEvent = false ; foreach ( $ entries as $ event ) { // Obtain th first event. if ( ! $ firstEvent ) { $ firstEvent = $ event ; } $ lastEvent = $ event ; // Find the current event if ( $ event -> id ( ) == $ this -> currentEvent ( ) [ 'id' ] ) { $ isNext = true ; $ isPrev = true ; continue ; } if ( ! $ isPrev ) { $ this -> prevEvent = $ event ; } // Store the next event if ( $ isNext ) { $ this -> nextEvent = $ event ; $ isNext = false ; } } if ( $ this -> entryCycle ( ) ) { if ( ! $ this -> nextEvent ) { $ this -> nextEvent = $ firstEvent ; } if ( ! $ this -> prevEvent ) { $ this -> prevEvent = $ lastEvent ; } } return $ this ; }
Set the Prev and Next event
@return $this
Set the Prev and Next event