Skip to content
This repository has been archived by the owner on Nov 11, 2020. It is now read-only.

Open up aggregation builder API for use in ODM #246

Merged
merged 4 commits into from
Nov 3, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/Doctrine/MongoDB/Aggregation/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/MongoDB/Aggregation/Expr.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/MongoDB/Aggregation/Stage.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ abstract class Stage
/**
* @var Builder
*/
private $builder;
protected $builder;

/**
* @param Builder $builder
Expand Down
17 changes: 16 additions & 1 deletion lib/Doctrine/MongoDB/Aggregation/Stage/Group.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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}
*/
Expand Down
4 changes: 2 additions & 2 deletions lib/Doctrine/MongoDB/Aggregation/Stage/Match.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function __construct(Builder $builder)
{
parent::__construct($builder);

$this->query = new Expr();
$this->query = $this->expr();
}

/**
Expand Down Expand Up @@ -196,7 +196,7 @@ public function exists($bool)
*/
public function expr()
{
return new Expr();
return $this->builder->matchExpr();
}

/**
Expand Down
4 changes: 2 additions & 2 deletions lib/Doctrine/MongoDB/Aggregation/Stage/Operator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/MongoDB/Aggregation/Stage/Out.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function __construct(Builder $builder, $collection)
{
parent::__construct($builder);

$this->collection = $collection;
$this->out($collection);
}

/**
Expand Down
1 change: 1 addition & 0 deletions lib/Doctrine/MongoDB/Aggregation/Stage/Project.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/

namespace Doctrine\MongoDB\Aggregation\Stage;

use Doctrine\MongoDB\Aggregation\Expr;

/**
Expand Down