deblan.io-murph/src/Analytic/DateRangeAnalytic.php

41 lines
895 B
PHP
Raw Permalink Normal View History

2022-04-19 16:11:51 +02:00
<?php
namespace App\Analytic;
use App\Core\Analytic\DateRangeAnalytic as BaseDateRangeAnalytic;
/**
* class DateRangeAnalytic.
*
* @author Simon Vieille <simon@deblan.fr>
*/
class DateRangeAnalytic extends BaseDateRangeAnalytic
{
protected string $page;
2022-09-06 16:12:30 +02:00
protected ?string $path;
2022-04-19 16:11:51 +02:00
public function setPath(string $path): self
{
2022-09-06 16:12:30 +02:00
$this->path = rtrim($path, '-');
2022-04-19 16:11:51 +02:00
$this->reload = true;
return $this;
}
protected function getEntities(string $type): array
{
$entities = parent::getEntities($type);
2022-04-19 16:24:53 +02:00
$newEntities = [];
2022-04-19 16:11:51 +02:00
foreach ($entities as $key => $entity) {
if ('view' === $type) {
2022-09-06 16:12:30 +02:00
if ($this->path === null || str_starts_with($entity->getPath(), $this->path)) {
2022-04-19 16:24:53 +02:00
$newEntities[] = $entity;
2022-04-19 16:11:51 +02:00
}
}
}
2022-04-19 16:24:53 +02:00
return $newEntities;
2022-04-19 16:11:51 +02:00
}
}