src/Charcoal/Cms/Service/Manager/EventManager.php
public function mapEvents()
    {
        if ($this->mapEvents) {
            return $this->mapEvents;
        }

        $events = $this->all();

        $out = [];
        foreach ($events as $ev) {
            $firstDate = $ev->startDate();
            $lastDate = $ev->endDate();

            $current = new DateTime();
            $current->setTimestamp($firstDate->getTimestamp());

            while ($current <= $lastDate) {
                $year = $current->format('Y');
                $month = $current->format('m');
                $day = $current->format('d');

                if (!isset($out[$year])) {
                    $out[$year] = [];
                }

                if (!isset($out[$year][$month])) {
                    $out[$year][$month] = [];
                }

                if (!isset($out[$year][$month][$day])) {
                    $out[$year][$month][$day] = [];
                }

                $out[$year][$month][$day][] = $ev;

                $current->modify('+1 day');
            }
        }

        $this->mapEvents = $out;

        return $this->mapEvents;
    }
public function mapEvents()
    {
        if ($this->mapEvents) {
            return $this->mapEvents;
        }

        $events = $this->all();

        $out = [];
        foreach ($events as $ev) {
            $firstDate = $ev->startDate();
            $lastDate = $ev->endDate();

            $current = new DateTime();
            $current->setTimestamp($firstDate->getTimestamp());

            while ($current <= $lastDate) {
                $year = $current->format('Y');
                $month = $current->format('m');
                $day = $current->format('d');

                if (!isset($out[$year])) {
                    $out[$year] = [];
                }

                if (!isset($out[$year][$month])) {
                    $out[$year][$month] = [];
                }

                if (!isset($out[$year][$month][$day])) {
                    $out[$year][$month][$day] = [];
                }

                $out[$year][$month][$day][] = $ev;

                $current->modify('+1 day');
            }
        }

        $this->mapEvents = $out;

        return $this->mapEvents;
    }
public function mapEvents ( ) { if ( $ this -> mapEvents ) { return $ this -> mapEvents ; } $ events = $ this -> all ( ) ; $ out = [ ] ; foreach ( $ events as $ ev ) { $ firstDate = $ ev -> startDate ( ) ; $ lastDate = $ ev -> endDate ( ) ; $ current = new DateTime ( ) ; $ current -> setTimestamp ( $ firstDate -> getTimestamp ( ) ) ; while ( $ current <= $ lastDate ) { $ year = $ current -> format ( 'Y' ) ; $ month = $ current -> format ( 'm' ) ; $ day = $ current -> format ( 'd' ) ; if ( ! isset ( $ out [ $ year ] ) ) { $ out [ $ year ] = [ ] ; } if ( ! isset ( $ out [ $ year ] [ $ month ] ) ) { $ out [ $ year ] [ $ month ] = [ ] ; } if ( ! isset ( $ out [ $ year ] [ $ month ] [ $ day ] ) ) { $ out [ $ year ] [ $ month ] [ $ day ] = [ ] ; } $ out [ $ year ] [ $ month ] [ $ day ] [ ] = $ ev ; $ current -> modify ( '+1 day' ) ; } } $ this -> mapEvents = $ out ; return $ this -> mapEvents ; }
Mapping between events and dates
@return array The array containing events stored as [$year][$month][$day][event]
Mapping between events and dates