handle post url update for analytics
This commit is contained in:
parent
fc34ce7e05
commit
547c628461
|
@ -12,10 +12,11 @@ use App\Core\Analytic\DateRangeAnalytic as BaseDateRangeAnalytic;
|
||||||
class DateRangeAnalytic extends BaseDateRangeAnalytic
|
class DateRangeAnalytic extends BaseDateRangeAnalytic
|
||||||
{
|
{
|
||||||
protected string $page;
|
protected string $page;
|
||||||
|
protected ?string $path;
|
||||||
|
|
||||||
public function setPath(string $path): self
|
public function setPath(string $path): self
|
||||||
{
|
{
|
||||||
$this->path = $path;
|
$this->path = rtrim($path, '-');
|
||||||
$this->reload = true;
|
$this->reload = true;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
@ -28,7 +29,7 @@ class DateRangeAnalytic extends BaseDateRangeAnalytic
|
||||||
|
|
||||||
foreach ($entities as $key => $entity) {
|
foreach ($entities as $key => $entity) {
|
||||||
if ('view' === $type) {
|
if ('view' === $type) {
|
||||||
if ($entity->getPath() === $this->path) {
|
if ($this->path === null || str_starts_with($entity->getPath(), $this->path)) {
|
||||||
$newEntities[] = $entity;
|
$newEntities[] = $entity;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -254,7 +254,7 @@ class PostAdminController extends CrudController
|
||||||
->setDateRange(new \DateTime('now - '.$range), new \DateTime())
|
->setDateRange(new \DateTime('now - '.$range), new \DateTime())
|
||||||
->setPath($this->generateUrl('blog_menu_post', [
|
->setPath($this->generateUrl('blog_menu_post', [
|
||||||
'post' => $entity->getId(),
|
'post' => $entity->getId(),
|
||||||
'slug' => $entity->getSlug(),
|
'slug' => '-',
|
||||||
]))
|
]))
|
||||||
->setNode($node)
|
->setNode($node)
|
||||||
;
|
;
|
||||||
|
|
Loading…
Reference in a new issue