/** * Creates the unwind for $field. * * @param string $field */ public function __construct($field) { // doing this supports not only mixed databases, but also allows us to unwind both strings and array $mixedFieldsBag = new MixedFieldsBag($field); $this->addBag($mixedFieldsBag); $unwind = new Unwind(); $unwind->setField($field); $this->add($unwind); }
/** * Gets test data for the pipeline builder. */ public function provideAggregationPipelineTestData() { $unwind1 = new Unwind(); $unwind1->setField('foo'); $unwind2 = new Unwind(); $unwind2->setField('bar'); $unwind3 = new Unwind(); $unwind3->setField('baz'); $bag = new AggregationBag(); $bag->addAggregation($unwind2); $builder = new PipelineBuilder(); $builder->add($unwind3); return [[[$unwind1], [['$unwind' => '$foo']]], [[$bag], [['$unwind' => '$bar']]], [[$builder], [['$unwind' => '$baz']]], [[$unwind1, $bag, $builder], [['$unwind' => '$foo'], ['$unwind' => '$bar'], ['$unwind' => '$baz']]]]; }
/** * Gets the unwind part. * * @param string $field */ private function getUnwind($field) { $unwind = new Unwind(); $unwind->setField($field . '_unwrapped'); return $unwind; }