Spaces:
No application file
No application file
File size: 2,125 Bytes
d2897cd |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
<?php
namespace Mautic\StatsBundle\Event;
use Mautic\StatsBundle\Aggregate\Collection\StatCollection;
use Mautic\StatsBundle\Event\Options\FetchOptions;
use Symfony\Contracts\EventDispatcher\Event;
class AggregateStatRequestEvent extends Event
{
private StatCollection $statCollection;
/**
* @param string $statName
*/
public function __construct(
private $statName,
private \DateTimeInterface $fromDateTime,
private \DateTimeInterface $toDateTime,
private FetchOptions $options
) {
$this->statCollection = new StatCollection();
}
/**
* Note if the listener handled collecting these stats.
*/
public function statsCollected(): void
{
$this->stopPropagation();
}
/**
* @return string
*/
public function getStatName()
{
return $this->statName;
}
/**
* @return \DateTimeInterface
*/
public function getFromDateTime()
{
return $this->fromDateTime;
}
/**
* @return \DateTimeInterface
*/
public function getToDateTime()
{
return $this->toDateTime;
}
/**
* @return FetchOptions
*/
public function getOptions()
{
return $this->options;
}
/**
* @return StatCollection
*/
public function getStatCollection()
{
return $this->statCollection;
}
/**
* @param string $context
*/
public function checkContext($context): bool
{
return $this->statName === $context;
}
public function checkContexts(array $contexts): bool
{
return in_array($this->statName, $contexts, true);
}
/**
* @param string $prefix
*/
public function checkContextPrefix($prefix): bool
{
return str_starts_with($this->statName, $prefix);
}
public function checkContextPrefixes(array $prefixes): bool
{
foreach ($prefixes as $string) {
if (str_starts_with($this->statName, $string)) {
return true;
}
}
return false;
}
}
|