public function getEventsItemized(\DateTime $start_date, \DateTime $end_date, $granularity = Event::BAT_HOURLY) {
    // The final events we will return
    $events = array();

    $keyed_units = $this->keyUnitsById();

    $db_events = $this->store->getEventData($start_date, $end_date, array_keys($keyed_units));

    // Create a mock itemized event for the period in question - since event data is either
    // in the database or the default value we first create a mock event and then fill it in
    // accordingly
    $mock_event = new Event($start_date, $end_date, new Unit(0,0), $this->default_value);
    $itemized = $mock_event->itemize(new EventItemizer($mock_event, $granularity));

    // Cycle through each unit retrieved and provide it with a fully configured itemized mock event
    foreach ($db_events as $unit => $event) {
      // Add the mock event
      $events[$unit] = $itemized;

      $events[$unit][Event::BAT_DAY] = $this->itemizeDays($db_events, $itemized, $unit, $keyed_units);

      // Handle hours
      if (isset($itemized[Event::BAT_HOUR]) || isset($db_events[$unit][Event::BAT_HOUR])) {
        $events[$unit][Event::BAT_HOUR] = $this->itemizeHours($db_events, $itemized, $unit, $keyed_units);
      } else {
        // No hours - set an empty array
        $events[$unit][Event::BAT_HOUR] = array();
      }

      // Handle minutes
      if (isset($itemized[Event::BAT_MINUTE]) || isset($db_events[$unit][Event::BAT_MINUTE])) {
        $events[$unit][Event::BAT_MINUTE] = $this->itemizeMinutes($db_events, $itemized, $unit, $keyed_units);
      } else {
        // No minutes - set an empty array
        $events[$unit][Event::BAT_MINUTE] = array();
      }

    }

    // Check to see if any events came back from the db
    foreach ($keyed_units as $id => $unit) {
      // If we don't have any db events add mock events (itemized)
      if ((isset($events[$id]) && count($events[$id]) == 0) || !isset($events[$id])) {
        $empty_event = new Event($start_date, $end_date, $unit, $unit->getDefaultValue());
        $events[$id] = $empty_event->itemize(new EventItemizer($empty_event, $granularity));
      }
    }

    return $events;
  }
public function getEventsItemized(\DateTime $start_date, \DateTime $end_date, $granularity = Event::BAT_HOURLY) {
    // The final events we will return
    $events = array();

    $keyed_units = $this->keyUnitsById();

    $db_events = $this->store->getEventData($start_date, $end_date, array_keys($keyed_units));

    // Create a mock itemized event for the period in question - since event data is either
    // in the database or the default value we first create a mock event and then fill it in
    // accordingly
    $mock_event = new Event($start_date, $end_date, new Unit(0,0), $this->default_value);
    $itemized = $mock_event->itemize(new EventItemizer($mock_event, $granularity));

    // Cycle through each unit retrieved and provide it with a fully configured itemized mock event
    foreach ($db_events as $unit => $event) {
      // Add the mock event
      $events[$unit] = $itemized;

      $events[$unit][Event::BAT_DAY] = $this->itemizeDays($db_events, $itemized, $unit, $keyed_units);

      // Handle hours
      if (isset($itemized[Event::BAT_HOUR]) || isset($db_events[$unit][Event::BAT_HOUR])) {
        $events[$unit][Event::BAT_HOUR] = $this->itemizeHours($db_events, $itemized, $unit, $keyed_units);
      } else {
        // No hours - set an empty array
        $events[$unit][Event::BAT_HOUR] = array();
      }

      // Handle minutes
      if (isset($itemized[Event::BAT_MINUTE]) || isset($db_events[$unit][Event::BAT_MINUTE])) {
        $events[$unit][Event::BAT_MINUTE] = $this->itemizeMinutes($db_events, $itemized, $unit, $keyed_units);
      } else {
        // No minutes - set an empty array
        $events[$unit][Event::BAT_MINUTE] = array();
      }

    }

    // Check to see if any events came back from the db
    foreach ($keyed_units as $id => $unit) {
      // If we don't have any db events add mock events (itemized)
      if ((isset($events[$id]) && count($events[$id]) == 0) || !isset($events[$id])) {
        $empty_event = new Event($start_date, $end_date, $unit, $unit->getDefaultValue());
        $events[$id] = $empty_event->itemize(new EventItemizer($empty_event, $granularity));
      }
    }

    return $events;
  }
public function getEventsItemized ( \ DateTime $ start_date , \ DateTime $ end_date , $ granularity = Event :: BAT_HOURLY ) { // The final events we will return $ events = array ( ) ; $ keyed_units = $ this -> keyUnitsById ( ) ; $ db_events = $ this -> store -> getEventData ( $ start_date , $ end_date , array_keys ( $ keyed_units ) ) ; // Create a mock itemized event for the period in question - since event data is either // in the database or the default value we first create a mock event and then fill it in // accordingly $ mock_event = new Event ( $ start_date , $ end_date , new Unit ( 0 , 0 ) , $ this -> default_value ) ; $ itemized = $ mock_event -> itemize ( new EventItemizer ( $ mock_event , $ granularity ) ) ; // Cycle through each unit retrieved and provide it with a fully configured itemized mock event foreach ( $ db_events as $ unit => $ event ) { // Add the mock event $ events [ $ unit ] = $ itemized ; $ events [ $ unit ] [ Event :: BAT_DAY ] = $ this -> itemizeDays ( $ db_events , $ itemized , $ unit , $ keyed_units ) ; // Handle hours if ( isset ( $ itemized [ Event :: BAT_HOUR ] ) || isset ( $ db_events [ $ unit ] [ Event :: BAT_HOUR ] ) ) { $ events [ $ unit ] [ Event :: BAT_HOUR ] = $ this -> itemizeHours ( $ db_events , $ itemized , $ unit , $ keyed_units ) ; } else { // No hours - set an empty array $ events [ $ unit ] [ Event :: BAT_HOUR ] = array ( ) ; } // Handle minutes if ( isset ( $ itemized [ Event :: BAT_MINUTE ] ) || isset ( $ db_events [ $ unit ] [ Event :: BAT_MINUTE ] ) ) { $ events [ $ unit ] [ Event :: BAT_MINUTE ] = $ this -> itemizeMinutes ( $ db_events , $ itemized , $ unit , $ keyed_units ) ; } else { // No minutes - set an empty array $ events [ $ unit ] [ Event :: BAT_MINUTE ] = array ( ) ; } } // Check to see if any events came back from the db foreach ( $ keyed_units as $ id => $ unit ) { // If we don't have any db events add mock events (itemized) if ( ( isset ( $ events [ $ id ] ) && count ( $ events [ $ id ] ) == 0 ) || ! isset ( $ events [ $ id ] ) ) { $ empty_event = new Event ( $ start_date , $ end_date , $ unit , $ unit -> getDefaultValue ( ) ) ; $ events [ $ id ] = $ empty_event -> itemize ( new EventItemizer ( $ empty_event , $ granularity ) ) ; } } return $ events ; }
Provides an itemized array of events keyed by the unit_id and divided by day,
hour and minute.

@param \DateTime $start_date
@param \DateTime $end_date
@param String $granularity

@return array
Provides an itemized array of events keyed by the unit_id and divided by day hour and minute .