/** * @param \Throwable $exception * @param string $filename * @param string $teaser * @param string $hash * @return Snapshot */ public function createFromException(\Throwable $exception, $filename, $teaser, $hash) { $fields = ['exception_hash' => $hash, 'filename' => $filename, 'exception_teaser' => $teaser, 'exception_classname' => get_class($exception), 'exception_message' => $exception->getMessage(), 'exception_line' => $exception->getLine(), 'exception_file' => $exception->getFile(), 'exception_code' => $exception->getCode()]; return $this->source->create($fields); }
/** * @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); } }