Skip to content

Commit 9038ef1

Browse files
author
Jasper van Herpt
committed
Allow additional mongo filters to be added in adapter options
1 parent 5f6e75e commit 9038ef1

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/Adapter/MongoDB/MongoDBAdapter.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ class MongoDBAdapter extends AbstractAdapter
3434

3535
/** @var Collection */
3636
private $collection;
37+
/** @var array */
38+
private $filters;
3739

3840
/**
3941
* {@inheritdoc}
@@ -45,6 +47,7 @@ public function configure(array $options)
4547
$options = $resolver->resolve($options);
4648

4749
$this->collection = $options['collection'];
50+
$this->filters = $options['filters'];
4851
}
4952

5053
/**
@@ -76,7 +79,7 @@ protected function getResults(AdapterQuery $query): \Traversable
7679
{
7780
$state = $query->getState();
7881

79-
$filter = [];
82+
$filter = $this->filters;
8083
$options = [
8184
'limit' => $state->getLength(),
8285
'skip' => $state->getStart(),
@@ -122,9 +125,11 @@ protected function configureOptions(OptionsResolver $resolver)
122125
{
123126
$resolver
124127
->setDefaults([
128+
'filters' => [],
125129
])
126130
->setRequired(['collection'])
127131
->setAllowedTypes('collection', \MongoDB\Collection::class)
132+
->setAllowedTypes('filters', 'array')
128133
;
129134
}
130135
}

0 commit comments

Comments
 (0)