public function execute()
{
$response = $this->doExecute();
$data = array();
if ($this->dm && $this->getParameter('include_docs') === true) {
$uow = $this->dm->getUnitOfWork();
foreach ($response->body['rows'] as $k => $v) {
$doc = $uow->createDocument(null, $v['doc']);
if ($this->toArray) {
$data[] = $doc;
} else {
if ($this->onlyDocs) {
$response->body['rows'][$k] = $doc;
} else {
$response->body['rows'][$k]['doc'] = $doc;
}
}
}
}
return $this->toArray ? $data : $this->createResult($response);
}