protected function _init()
{
parent::_init();
$this->_operators += array('like' => function ($key, $value) {
return new MongoRegex($value);
}, '$exists' => function ($key, $value) {
return array('$exists' => (bool) $value);
}, '$type' => function ($key, $value) {
return array('$type' => (int) $value);
}, '$mod' => function ($key, $value) {
$value = (array) $value;
return array('$mod' => array(current($value), next($value) ?: 0));
}, '$size' => function ($key, $value) {
return array('$size' => (int) $value);
}, '$elemMatch' => function ($operator, $values, $options = array()) {
$options += array('castOpts' => array(), 'field' => '');
$options['castOpts'] += array('pathKey' => $options['field']);
$values = (array) $values;
if (empty($options['castOpts']['schema'])) {
return array('$elemMatch' => $values);
}
foreach ($values as $key => &$value) {
$value = $options['castOpts']['schema']->cast(null, $key, $value, $options['castOpts']);
}
return array('$elemMatch' => $values);
});
}