handle post url update for analytics

This commit is contained in:
Simon Vieille 2022-09-06 16:12:30 +02:00
parent fc34ce7e05
commit 547c628461
Signed by: deblan
GPG key ID: 579388D585F70417
2 changed files with 4 additions and 3 deletions

View file

@ -12,10 +12,11 @@ use App\Core\Analytic\DateRangeAnalytic as BaseDateRangeAnalytic;
class DateRangeAnalytic extends BaseDateRangeAnalytic
{
protected string $page;
protected ?string $path;
public function setPath(string $path): self
{
$this->path = $path;
$this->path = rtrim($path, '-');
$this->reload = true;
return $this;
@ -28,7 +29,7 @@ class DateRangeAnalytic extends BaseDateRangeAnalytic
foreach ($entities as $key => $entity) {
if ('view' === $type) {
if ($entity->getPath() === $this->path) {
if ($this->path === null || str_starts_with($entity->getPath(), $this->path)) {
$newEntities[] = $entity;
}
}

View file

@ -254,7 +254,7 @@ class PostAdminController extends CrudController
->setDateRange(new \DateTime('now - '.$range), new \DateTime())
->setPath($this->generateUrl('blog_menu_post', [
'post' => $entity->getId(),
'slug' => $entity->getSlug(),
'slug' => '-',
]))
->setNode($node)
;