61 lines
1.4 KiB
PHP
61 lines
1.4 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace External\PompoBundle\View;
|
|
|
|
use External\PompoBundle\Util\User\UserCardUtil;
|
|
use KupShop\KupShopBundle\Context\UserContext;
|
|
use KupShop\KupShopBundle\Util\Contexts;
|
|
use KupShop\KupShopBundle\Views\View;
|
|
use Query\Operator;
|
|
|
|
class UserCardsView extends View
|
|
{
|
|
protected $template = 'user/user.cards.tpl';
|
|
|
|
private UserCardUtil $userCardUtil;
|
|
|
|
public function __construct(UserCardUtil $userCardUtil)
|
|
{
|
|
$this->userCardUtil = $userCardUtil;
|
|
}
|
|
|
|
public function getTitle()
|
|
{
|
|
return translate('userCardsTitle', 'pompo');
|
|
}
|
|
|
|
public function getBodyVariables()
|
|
{
|
|
$vars = parent::getBodyVariables();
|
|
|
|
$vars['cards'] = $this->userCardUtil->getUserCards(
|
|
$this->getUserId()
|
|
);
|
|
$vars['children'] = $this->getUserChildren();
|
|
|
|
return $vars;
|
|
}
|
|
|
|
public function getUserChildren(): string
|
|
{
|
|
$qb = sqlQueryBuilder()
|
|
->select('name')
|
|
->from('users_family')
|
|
->where(Operator::equals(['id_user' => $this->getUserId()]));
|
|
|
|
$result = [];
|
|
foreach ($qb->execute() as $item) {
|
|
$result[] = $item['name'];
|
|
}
|
|
|
|
return implode(', ', array_filter($result));
|
|
}
|
|
|
|
public function getUserId(): int
|
|
{
|
|
return (int) Contexts::get(UserContext::class)->getActiveId();
|
|
}
|
|
}
|