first commit
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace KupShop\BonusProgramBundle\View;
|
||||
|
||||
use KupShop\BonusProgramBundle\Utils\BonusProvider;
|
||||
use KupShop\KupShopBundle\Views\Traits\RequestTrait;
|
||||
use KupShop\KupShopBundle\Views\Traits\SecurityTrait;
|
||||
use KupShop\KupShopBundle\Views\View;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
class BonusProgramHistoryView extends View
|
||||
{
|
||||
use RequestTrait;
|
||||
use SecurityTrait;
|
||||
|
||||
protected string $smartyFallback = 'account';
|
||||
protected string $entrypoint = 'account';
|
||||
protected $template = 'bonus_program.history.tpl';
|
||||
protected $title;
|
||||
|
||||
protected \Pager $pager;
|
||||
|
||||
public function __construct(protected BonusProvider $bonusProvider)
|
||||
{
|
||||
$this->requirements = [
|
||||
'logged_user' => true,
|
||||
];
|
||||
|
||||
$this->pager = new \Pager();
|
||||
}
|
||||
|
||||
public function getResponse(?Request $request = null)
|
||||
{
|
||||
$this->checkRequirements();
|
||||
|
||||
return parent::getResponse($request);
|
||||
}
|
||||
|
||||
public function getBodyVariables()
|
||||
{
|
||||
$data = parent::getBodyVariables();
|
||||
|
||||
$data['user'] = \User::getCurrentUser();
|
||||
|
||||
$this->pager->setPageNumber($this->request->get('page', 1));
|
||||
$this->pager->setTotal($this->bonusProvider->getPointsHistoryCount(\User::getCurrentUserId()));
|
||||
$data['pager'] = $this->pager;
|
||||
|
||||
$data['active_points'] = $this->bonusProvider->getActivePointsAmount(\User::getCurrentUserId());
|
||||
$data['points_history'] = $this->bonusProvider->getPointsHistory(\User::getCurrentUserId(), $this->pager->getSpec());
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function getTitle()
|
||||
{
|
||||
return translate('bonus_program_title', 'bonus_program');
|
||||
}
|
||||
|
||||
public function getBreadcrumbs()
|
||||
{
|
||||
return getReturnNavigation(-1, 'USER', [$this->getTitle()]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user