You are here

public function ReservationConflicts::fillBuckets in MERCI (Manage Equipment Reservations, Checkout and Inventory) 8.2

1 call to ReservationConflicts::fillBuckets()
ReservationConflicts::validate in src/ReservationConflicts.php

File

src/ReservationConflicts.php, line 424
Contains \Drupal\merci\ReservationConflicts. Abstraction of the selection logic of an entity reference field.

Class

ReservationConflicts
A null implementation of EntityReference_SelectionHandler.

Namespace

Drupal\merci

Code

public function fillBuckets() {
  $conflicts = array();
  $dates = $this->entity
    ->get($this->date_field);
  foreach ($dates as $date) {
    $date_value = $date
      ->get('value')
      ->getValue();
    $result = $this
      ->bestFit($date);

    // Result is array indexed by $delta of filled buckets.
    foreach ($result as $delta => $buckets) {
      if (!isset($conflicts[$delta])) {
        $conflicts[$delta] = array();
      }
      $conflicts[$delta][$date_value] = $buckets;
    }
  }
  return $conflicts;
}