diff --git a/lib/Doctrine/MongoDB/Aggregation/Builder.php b/lib/Doctrine/MongoDB/Aggregation/Builder.php index f73a9d94..b5109e3b 100644 --- a/lib/Doctrine/MongoDB/Aggregation/Builder.php +++ b/lib/Doctrine/MongoDB/Aggregation/Builder.php @@ -303,7 +303,7 @@ public function unwind($fieldName) * @param Stage $stage * @return Stage */ - private function addStage(Stage $stage) + protected function addStage(Stage $stage) { $this->stages[] = $stage; diff --git a/lib/Doctrine/MongoDB/Aggregation/Expr.php b/lib/Doctrine/MongoDB/Aggregation/Expr.php index 7f0e68a7..d96759c7 100644 --- a/lib/Doctrine/MongoDB/Aggregation/Expr.php +++ b/lib/Doctrine/MongoDB/Aggregation/Expr.php @@ -286,7 +286,7 @@ public function cond($if, $then, $else) * @param mixed|self $expression * @return mixed */ - private function ensureArray($expression) + protected function ensureArray($expression) { if (is_array($expression)) { $array = []; diff --git a/lib/Doctrine/MongoDB/Aggregation/Stage.php b/lib/Doctrine/MongoDB/Aggregation/Stage.php index 8a7059b4..14f8b355 100644 --- a/lib/Doctrine/MongoDB/Aggregation/Stage.php +++ b/lib/Doctrine/MongoDB/Aggregation/Stage.php @@ -33,7 +33,7 @@ abstract class Stage /** * @var Builder */ - private $builder; + protected $builder; /** * @param Builder $builder diff --git a/lib/Doctrine/MongoDB/Aggregation/Stage/Group.php b/lib/Doctrine/MongoDB/Aggregation/Stage/Group.php index 73bd30b9..3bf42cf5 100644 --- a/lib/Doctrine/MongoDB/Aggregation/Stage/Group.php +++ b/lib/Doctrine/MongoDB/Aggregation/Stage/Group.php @@ -19,8 +19,8 @@ namespace Doctrine\MongoDB\Aggregation\Stage; +use Doctrine\MongoDB\Aggregation\Builder; use Doctrine\MongoDB\Aggregation\Expr; -use Doctrine\MongoDB\Aggregation\Stage; /** * Fluent interface for adding a $group stage to an aggregation pipeline. @@ -30,6 +30,21 @@ */ class Group extends Operator { + /** + * @var Expr + */ + protected $expr; + + /** + * {@inheritdoc} + */ + public function __construct(Builder $builder) + { + parent::__construct($builder); + + $this->expr = $builder->expr(); + } + /** * {@inheritdoc} */ diff --git a/lib/Doctrine/MongoDB/Aggregation/Stage/Match.php b/lib/Doctrine/MongoDB/Aggregation/Stage/Match.php index e90c255a..875d46d6 100644 --- a/lib/Doctrine/MongoDB/Aggregation/Stage/Match.php +++ b/lib/Doctrine/MongoDB/Aggregation/Stage/Match.php @@ -44,7 +44,7 @@ public function __construct(Builder $builder) { parent::__construct($builder); - $this->query = new Expr(); + $this->query = $this->expr(); } /** @@ -196,7 +196,7 @@ public function exists($bool) */ public function expr() { - return new Expr(); + return $this->builder->matchExpr(); } /** diff --git a/lib/Doctrine/MongoDB/Aggregation/Stage/Operator.php b/lib/Doctrine/MongoDB/Aggregation/Stage/Operator.php index 0d881988..bd95835d 100644 --- a/lib/Doctrine/MongoDB/Aggregation/Stage/Operator.php +++ b/lib/Doctrine/MongoDB/Aggregation/Stage/Operator.php @@ -41,9 +41,9 @@ abstract class Operator extends Stage */ public function __construct(Builder $builder) { - $this->expr = new Expr(); - parent::__construct($builder); + + $this->expr = $builder->expr(); } /** diff --git a/lib/Doctrine/MongoDB/Aggregation/Stage/Out.php b/lib/Doctrine/MongoDB/Aggregation/Stage/Out.php index 0a50b4aa..a4d35d90 100644 --- a/lib/Doctrine/MongoDB/Aggregation/Stage/Out.php +++ b/lib/Doctrine/MongoDB/Aggregation/Stage/Out.php @@ -43,7 +43,7 @@ public function __construct(Builder $builder, $collection) { parent::__construct($builder); - $this->collection = $collection; + $this->out($collection); } /** diff --git a/lib/Doctrine/MongoDB/Aggregation/Stage/Project.php b/lib/Doctrine/MongoDB/Aggregation/Stage/Project.php index 98769dd3..c80b0fbc 100644 --- a/lib/Doctrine/MongoDB/Aggregation/Stage/Project.php +++ b/lib/Doctrine/MongoDB/Aggregation/Stage/Project.php @@ -18,6 +18,7 @@ */ namespace Doctrine\MongoDB\Aggregation\Stage; + use Doctrine\MongoDB\Aggregation\Expr; /**