PHP Класс Roomify\Bat\Calendar\AbstractCalendar

Наследование: implements Roomify\Bat\Calendar\CalendarInterface
Показать файл Открыть проект

Защищенные свойства (Protected)

Свойство Тип Описание
$default_value The default value for events. In the event store this is represented by 0 which is then replaced by the default value provided in the constructor.
$itemized_events Stores itemized events allowing us to perform searches over them without having to pull them out of storage (i.e. reducing DB calls)
$store The class that will access the actual event store where event data is held.
$units array The units we are dealing with. If no unit ids set the calendar will return results for date range and all units within that range.

Открытые методы

Метод Описание
addEvents ( $events, $granularity )
getEvents ( DateTime $start_date, DateTime $end_date, $reset = TRUE ) : array Given a start and end time will retrieve events from the defined store.
getEventsItemized ( DateTime $start_date, DateTime $end_date, String $granularity = Event::BAT_HOURLY ) : array Provides an itemized array of events keyed by the unit_id and divided by day, hour and minute.
getEventsNormalized ( DateTime $start_date, DateTime $end_date, $events ) : array Given an itemized set of event data it will return an array of Events
getMatchingUnits ( DateTime $start_date, DateTime $end_date, $valid_states, $constraints = [], $intersect = FALSE, $reset = TRUE ) : Roomify\Bat\Calendar\CalendarResponse Given a date range and a set of valid states it will return all units within the set of valid states.
getStates ( DateTime $start_date, DateTime $end_date, $reset = TRUE ) : array Given a start and end time this will return the states units find themselves in for that range.
groupData ( $data, $length ) A simple utility function that given an array of datum=>value will group results based on those that have the same value. Useful for grouping events based on state.

Защищенные методы

Метод Описание
getUnit ( $unit_id ) : Roomify\Bat\Unit\Unit Returns the unit object.
getUnitIds ( ) : array Return an array of unit ids from the set of units supplied to the Calendar.
keyUnitsById ( ) : array Return an array of units keyed by unit id

Приватные методы

Метод Описание
itemizeDays ( $db_events, $itemized, $unit, $keyed_units ) : array Helper function that cycles through db results and setups the BAT_DAY itemized array
itemizeHours ( $db_events, $itemized, $unit, $keyed_units ) : array Helper function that cycles through db results and setups the BAT_HOUR itemized array
itemizeMinutes ( $db_events, $itemized, $unit, $keyed_units ) : array Helper function that cycles through db results and setups the BAT_MINUTE itemized array

Описание методов

addEvents() публичный Метод

public addEvents ( $events, $granularity )

getEvents() публичный Метод

If unit_ids where defined it will filter for those unit ids.
public getEvents ( DateTime $start_date, DateTime $end_date, $reset = TRUE ) : array
$start_date DateTime
$end_date DateTime
$reset - if set to TRUE we will always refer to the Store to retrieve events
Результат array

getEventsItemized() публичный Метод

Provides an itemized array of events keyed by the unit_id and divided by day, hour and minute.
public getEventsItemized ( DateTime $start_date, DateTime $end_date, String $granularity = Event::BAT_HOURLY ) : array
$start_date DateTime
$end_date DateTime
$granularity String
Результат array

getEventsNormalized() публичный Метод

Given an itemized set of event data it will return an array of Events
public getEventsNormalized ( DateTime $start_date, DateTime $end_date, $events ) : array
$start_date DateTime
$end_date DateTime
$events
Результат array

getMatchingUnits() публичный Метод

If intersect is set to TRUE a unit will report as matched as long as within the time period requested it finds itself at least once within a valid state. Alternatively units will match ONLY if they find themselves withing the valid states and no other state.
public getMatchingUnits ( DateTime $start_date, DateTime $end_date, $valid_states, $constraints = [], $intersect = FALSE, $reset = TRUE ) : Roomify\Bat\Calendar\CalendarResponse
$start_date DateTime
$end_date DateTime
$valid_states
$constraints
$intersect - performs an intersect rather than a diff on valid states
$reset - if set to true we refer to the Store to retrieve events
Результат Roomify\Bat\Calendar\CalendarResponse

getStates() публичный Метод

Given a start and end time this will return the states units find themselves in for that range.
public getStates ( DateTime $start_date, DateTime $end_date, $reset = TRUE ) : array
$start_date DateTime
$end_date DateTime
$reset - if set to TRUE we will refer to the Store to retrieve events
Результат array An array of states keyed by unit

getUnit() защищенный Метод

Returns the unit object.
protected getUnit ( $unit_id ) : Roomify\Bat\Unit\Unit
$unit_id
Результат Roomify\Bat\Unit\Unit

getUnitIds() защищенный Метод

Return an array of unit ids from the set of units supplied to the Calendar.
protected getUnitIds ( ) : array
Результат array

groupData() публичный Метод

A simple utility function that given an array of datum=>value will group results based on those that have the same value. Useful for grouping events based on state.
public groupData ( $data, $length )
$data
$length

keyUnitsById() защищенный Метод

Return an array of units keyed by unit id
protected keyUnitsById ( ) : array
Результат array

Описание свойств

$default_value защищенное свойство

The default value for events. In the event store this is represented by 0 which is then replaced by the default value provided in the constructor.
protected $default_value

$itemized_events защищенное свойство

Stores itemized events allowing us to perform searches over them without having to pull them out of storage (i.e. reducing DB calls)
protected $itemized_events

$store защищенное свойство

The class that will access the actual event store where event data is held.
protected $store

$units защищенное свойство

The units we are dealing with. If no unit ids set the calendar will return results for date range and all units within that range.
protected array $units
Результат array