<?php
namespace App\Twig;
use App\Service\Client\BonusService;
use App\Service\Client\MarketingImageService;
use App\Service\Client\User\MemberOnlineService;
use Twig\Extension\AbstractExtension;
use Twig\TwigFunction;
class SidebarExtension extends AbstractExtension
{
protected BonusService $bonusService;
protected \Redis $redis;
public function __construct(BonusService $bonusService, \Redis $redis, private MarketingImageService $marketingImageService)
{
$this->bonusService = $bonusService;
$this->redis = $redis;
}
public function getFunctions(): array
{
return [
new TwigFunction('femaleOnlineUsersSoftcore', [$this, 'getFemaleOnlineUsersSoftcore']),
new TwigFunction('maleOnlineUsersSoftcore', [$this, 'getMaleOnlineUsersSoftcore']),
new TwigFunction('getCurrentBonus', [$this, 'getCurrentBonus']),
new TwigFunction('getCurrentMarketingImage', [$this, 'getCurrentMarketingImage']),
];
}
public function getFemaleOnlineUsersSoftcore(): array
{
return MemberOnlineService::getOnlineUsersSidebarHtml($this->redis, false)[0];
}
public function getMaleOnlineUsersSoftcore(): array
{
return MemberOnlineService::getOnlineUsersSidebarHtml($this->redis, false)[1];
}
public function getCurrentBonus(): ?array
{
return $this->bonusService->getCurrentBonus();
}
public function getCurrentMarketingImage(): ?array {
return $this->marketingImageService->getCurrentMarketingImage();
}
}