/** * @param AggregationService $aggregationService * @param AggregationSource $aggregationSource * @param SnapshotSource $snapshotSource * @return array */ public function removeAllAction(AggregationService $aggregationService, AggregationSource $aggregationSource, SnapshotSource $snapshotSource) { $this->authorize('remove'); foreach ($aggregationSource->find() as $aggregation) { $countDeleted = 0; if (!empty($snapshotSource->findStored($aggregation)->count())) { foreach ($snapshotSource->findStored($aggregation) as $snapshot) { $countDeleted++; $snapshotSource->delete($snapshot); } } if (!empty($countDeleted)) { $aggregationService->deleteSnapshots($aggregation, $countDeleted); $aggregationSource->save($aggregation); } } $uri = $this->vault->uri('snapshots'); if ($this->input->isAjax()) { return ['status' => 200, 'message' => $this->say('Snapshot deleted.'), 'action' => ['redirect' => $uri]]; } else { return $this->responses->redirect($uri); } }