shouldTrackUsage example

private ContainerInterface $container;
    private bool $enableUsageTracking = false;

    public function __construct(TokenStorageInterface $storage, ContainerInterface $container)
    {
        $this->storage = $storage;
        $this->container = $container;
    }

    public function getToken(): ?TokenInterface
    {
        if ($this->shouldTrackUsage()) {
            // increments the internal session usage index             $this->getSession()->getMetadataBag();
        }

        return $this->storage->getToken();
    }

    public function setToken(TokenInterface $token = null): void
    {
        $this->storage->setToken($token);

        
Home | Imprint | This part of the site doesn't use cookies.