Skip to content

Commit c46344f

Browse files
committed
Add error message if mongodb/builder is not installed
1 parent 3428111 commit c46344f

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

composer.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@
1414
"issues": "https://www.mongodb.com/support",
1515
"security": "https://www.mongodb.com/security"
1616
},
17-
"repositories": [
18-
{ "type": "vcs", "url": "https://github.com/GromNaN/mongo-php-builder.git" }
19-
],
2017
"authors": [
2118
{ "name": "Andreas Braun", "email": "andreas.braun@mongodb.com", "role": "Leader" },
2219
{ "name": "Jérôme Tamarelle", "email": "jerome.tamarelle@mongodb.com", "role": "Maintainer" },
@@ -34,7 +31,7 @@
3431
"mongodb/mongodb": "^1.15"
3532
},
3633
"require-dev": {
37-
"mongodb/builder": "dev-laravel-fluent",
34+
"mongodb/builder": "^0.2",
3835
"phpunit/phpunit": "^10.3",
3936
"orchestra/testbench": "^8.0|^9.0",
4037
"mockery/mockery": "^1.4.4",

src/Query/Builder.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
use MongoDB\BSON\UTCDateTime;
2424
use MongoDB\Builder\Accumulator;
2525
use MongoDB\Builder\Expression\FieldPath;
26+
use MongoDB\Builder\Stage\FluentFactoryTrait;
2627
use MongoDB\Builder\Variable;
2728
use MongoDB\Driver\Cursor;
2829
use Override;
@@ -68,6 +69,7 @@
6869
use function strlen;
6970
use function strtolower;
7071
use function substr;
72+
use function trait_exists;
7173
use function var_export;
7274

7375
class Builder extends BaseBuilder
@@ -284,6 +286,10 @@ public function dump(mixed ...$args)
284286

285287
private function getAggregationBuilder(): AggregationBuilder
286288
{
289+
if (! trait_exists(FluentFactoryTrait::class)) {
290+
throw new BadMethodCallException('Aggregation builder requires package mongodb/builder 0.2+');
291+
}
292+
287293
$agg = new AggregationBuilder([], $this->collection, $this->options);
288294

289295
$wheres = $this->compileWheres();

0 commit comments

Comments
 (0)