protected function _conditions(array $conditions, $model, $schema, $context)
{
$ops = $this->_operators;
$castOpts = array('first' => true, 'database' => $this, 'wrap' => false, 'asContent' => true);
$cast = function ($key, $value) use(&$schema, &$castOpts) {
return $schema ? $schema->cast(null, $key, $value, $castOpts) : $value;
};
foreach ($conditions as $key => $value) {
if (in_array($key, $this->_boolean)) {
$operator = isset($ops[$key]) ? $ops[$key] : $key;
foreach ($value as $i => $compare) {
$value[$i] = $this->_conditions($compare, $model, $schema, $context);
}
unset($conditions[$key]);
$conditions[$operator] = $value;
continue;
}
if (is_object($value)) {
continue;
}
if (!is_array($value)) {
$conditions[$key] = $cast($key, $value);
continue;
}
$current = key($value);
if (!isset($ops[$current]) && $current[0] !== '$') {
$conditions[$key] = array('$in' => $cast($key, $value));
continue;
}
$conditions[$key] = $this->_operators($key, $value, $schema);
}
return $conditions;
}