protected function BatTypeController::applyConditions in Booking and Availability Management Tools for Drupal 7
1 call to BatTypeController::applyConditions()
- BatTypeController::cacheGet in modules/
bat_unit/ bat_unit.module - Overridden.
File
- modules/
bat_unit/ bat_unit.module, line 2134
Class
- BatTypeController
- The Controller for BatType entities.
Code
protected function applyConditions($entities, $conditions = array()) {
if ($conditions) {
foreach ($entities as $key => $entity) {
$entity_values = (array) $entity;
// We cannot use array_diff_assoc() here because condition values can
// also be arrays, e.g. '$conditions = array('status' => array(1, 2))'.
foreach ($conditions as $condition_key => $condition_value) {
if (is_array($condition_value)) {
if (!isset($entity_values[$condition_key]) || !in_array($entity_values[$condition_key], $condition_value)) {
unset($entities[$key]);
}
}
elseif (!isset($entity_values[$condition_key]) || $entity_values[$condition_key] != $condition_value) {
unset($entities[$key]);
}
}
}
}
return $entities;
}