/** * Gather all reservations. * * @since 0.2.0 * @access protected * @return \Wprsrv\PostTypes\Objects\Reservation[] */ protected function getReservations() { $reservations = []; $rargs = ['post_type' => 'reservation', 'post_status' => ['reservation_pending', 'reservation_accepted', 'reservation_declined'], 'posts_per_page' => -1, 'nopaging' => 1, 'no_found_rows' => true, 'meta_key' => '_wprsrv_reservable_id']; if ($this->reservable) { $reservations = $this->reservable->getReservations(); } else { $reservationsQuery = new \WP_Query($rargs); foreach ($reservationsQuery->posts as $rpost) { $reservations[] = new Reservation($rpost); } } return $reservations; }
/** * Constructor. * * @since 0.1.0 * * @param Reservable $reservable Reservable to create calendar for. * @param \DateTime $date DateTime object to use for year and month. * * @return void */ public function __construct(Reservable $reservable, \DateTime $date, $firstOrLast = null) { $this->reservable = $reservable; $this->date = $date; $this->year = (int) $date->format('Y'); $this->month = (int) $date->format('m'); $this->daysInMonth = $date->format('t'); // Is this the first or last calendar in a set of calendars. if ($firstOrLast !== null) { if ($firstOrLast === 'first') { $this->isFirstCalendar = true; } elseif ($firstOrLast === 'last') { $this->isLastCalendar = true; } } $this->reservations = $this->reservable->getReservations(); $this->transientKey = 'wprsrv_reservable' . $this->reservable->ID . 'cal' . $this->year . $this->month; }