/**
  * {@inheritdoc}
  */
 public function report()
 {
     $this->logger->error($this->getMessage());
     if (!$this->config->reportingEnabled()) {
         //No need to record anything
         return;
     }
     $teaser = $this->getMessage();
     $hash = $this->hash($teaser);
     $exception = $this->getException();
     $filename = $this->config->snapshotFilename($exception, time());
     $snapshot = $this->snapshotService->createFromException($exception, $filename, $teaser, $hash);
     $snapshotSource = $this->snapshotService->getSource();
     $snapshotSource->save($snapshot);
     $aggregation = $this->aggregationService->findOrCreateByHash($hash, $teaser);
     $suppress = $snapshotSource->findStored($aggregation)->count() ? $aggregation->isSuppressionEnabled() : false;
     $this->aggregationService->addSnapshot($aggregation, $snapshot, $suppress);
     $this->aggregationService->getSource()->save($aggregation);
     $snapshotSource->save($snapshot);
     if ($suppress) {
         //No need to create file
         return;
     }
     $this->saveSnapshot();
 }
 /**
  * @param string             $id
  * @param SnapshotSource     $snapshotSource
  * @param AggregationService $aggregationService
  * @return array
  */
 public function removeSnapshotAction($id, SnapshotSource $snapshotSource, AggregationService $aggregationService)
 {
     /**
      * @var Snapshot    $snapshot
      * @var Aggregation $aggregation
      */
     $snapshot = $snapshotSource->findByPK($id);
     if (empty($snapshot)) {
         throw new NotFoundException();
     }
     if (!$snapshot->stored()) {
         throw new ForbiddenException();
     }
     $aggregation = $aggregationService->getSource()->findBySnapshot($snapshot);
     if (empty($aggregation)) {
         throw new NotFoundException();
     }
     $this->authorize('remove', compact('aggregation', 'snapshot'));
     $aggregationService->deleteSnapshots($aggregation, 1);
     $aggregationService->getSource()->save($aggregation);
     $snapshotSource->delete($snapshot);
     $uri = $this->vault->uri('snapshots:edit', ['id' => $aggregation->id]);
     if ($this->input->isAjax()) {
         return ['status' => 200, 'message' => $this->say('Snapshot deleted.'), 'action' => ['redirect' => $uri]];
     } else {
         return $this->responses->redirect($uri);
     }
 }