You are here

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

Overrides ReservationConflictsInterface::validate

3 calls to ReservationConflicts::validate()
ReservationConflicts::getConflicts in src/ReservationConflicts.php
ReservationConflicts::getErrors in src/ReservationConflicts.php
ReservationConflicts::getTotalBucketsFilled in src/ReservationConflicts.php

File

src/ReservationConflicts.php, line 80
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 validate() {
  if (!$this->validated) {
    $this->buckets = $this
      ->fillBuckets();
    $this->validated = TRUE;
    $conflicts = array();
    foreach ($this->buckets as $delta => $dates) {
      foreach ($dates as $date_value => $buckets) {
        if (!isset($this->total_buckets_filled[$delta])) {
          $this->total_buckets_filled[$delta] = array();
        }
        $this->total_buckets_filled[$delta][$date_value] = count($buckets);
        if (!isset($conflicts[$delta])) {
          $conflicts[$delta] = array();
        }
        $conflicts[$delta][$date_value] = array();
        foreach ($buckets as $bucket) {
          $conflicts[$delta][$date_value] = array_merge($conflicts[$delta][$date_value], $bucket);
        }
      }
    }
    $this->conflicting_entities = $conflicts;
  }
}