diff --git a/core/Entity/NodeView.php b/core/Entity/NodeView.php new file mode 100644 index 0000000..506dbb5 --- /dev/null +++ b/core/Entity/NodeView.php @@ -0,0 +1,102 @@ +id; + } + + public function getNode(): ?Node + { + return $this->node; + } + + public function setNode(?Node $node): self + { + $this->node = $node; + + return $this; + } + + public function getPath(): ?string + { + return $this->path; + } + + public function setPath(string $path): self + { + $this->path = $path; + + return $this; + } + + public function getViews(): ?int + { + return $this->views; + } + + public function setViews(int $views): self + { + $this->views = $views; + + return $this; + } + + public function addView(): self + { + ++$this->views; + + return $this; + } + + public function getDate(): ?\DateTimeInterface + { + return $this->date; + } + + public function setDate(\DateTimeInterface $date): self + { + $this->date = $date; + + return $this; + } +} diff --git a/core/Factory/NodeViewFactory.php b/core/Factory/NodeViewFactory.php new file mode 100644 index 0000000..ecc3862 --- /dev/null +++ b/core/Factory/NodeViewFactory.php @@ -0,0 +1,21 @@ +setNode($node) + ->setPath($path) + ->setDate(new \DateTime()) + ; + + return $entity; + } +} diff --git a/core/Repository/NodeViewRepository.php b/core/Repository/NodeViewRepository.php new file mode 100644 index 0000000..5175e58 --- /dev/null +++ b/core/Repository/NodeViewRepository.php @@ -0,0 +1,21 @@ +andWhere('.node = :node') + ->andWhere('.path = :path') + ->setParameters([ + ':node' => $request->attributes->get('_node'), + ':path' => $request->getPathInfo(), + ]) + ; + } +}