/**
* Aggregates the statements in the LRS (with the $lrsId) with the $pipeline.
* @param string $lrsId
* @param [mixed] $pipeline
* @return [Aggregate] http://php.net/manual/en/mongocollection.aggregate.php#refsect1-mongocollection.aggregate-examples
*/
public function aggregate($lrsId, array $pipeline)
{
if (strpos(json_encode($pipeline), '$out') !== false) {
return;
}
$pipeline[0]['$match'] = ['$and' => [(object) $pipeline[0]['$match'], [self::LRS_ID_KEY => $lrsId, 'active' => true]]];
return Helpers::replaceHtmlEntity($this->db->statements->aggregate($pipeline), true);
}