<commit_before><?php

namespace App\Admin;

use App\Entity\Payment;
use App\Repository\EventRepository;
use Doctrine\Common\Collections\Criteria;
use Sonata\AdminBundle\Admin\AbstractAdmin;
use Sonata\AdminBundle\Datagrid\DatagridMapper;
use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Form\FormMapper;
use Sonata\AdminBundle\Route\RouteCollection;
use Sonata\AdminBundle\Show\ShowMapper;
use Sonata\Form\Type\DateTimePickerType;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\MoneyType;
use Symfony\Component\Form\Extension\Core\Type\TextType;

/**
 * Class TicketAdmin.
 */
final class TicketAdmin extends AbstractAdmin
{
    /** @var EventRepository */
    private $eventRepository;

    /**
     * Default Datagrid values.
     *
     * @var array
     */
    protected $datagridValues =
        [
            '_page' => 1,
            '_sort_order' => 'DESC',
            '_sort_by' => 'id',
        ];

    /**
     * @param string          $code
     * @param string          $class
     * @param string          $baseControllerName
     * @param EventRepository $eventRepository
     */
    public function __construct($code, $class, $baseControllerName, EventRepository $eventRepository)
    {
        parent::__construct($code, $class, $baseControllerName);
        $this->eventRepository = $eventRepository;
    }

    /**
     * @return array
     */
    public function getExportFields(): array
    {
        return [
            'id',
            'event',
            'user.fullname',
            'user.email',
            'user.phone',
            'amount',
            'amountWithoutDiscount',
            'payment',
            'createdAt',
            'updatedAt',
            'used',
        ];
    }

    /**
     * @param RouteCollection $collection
     */
    protected function configureRoutes(RouteCollection $collection): void
    {
        $collection->remove('create');
        $collection->add('remove_paid_ticket_from_payment', $this->getRouterIdParameter().'/remove_paid_ticket_from_payment');
        $collection->add('download', $this->getRouterIdParameter().'/download');
    }

    /**
     * @param ListMapper $listMapper
     */
    protected function configureListFields(ListMapper $listMapper): void
    {
        $listMapper
            ->addIdentifier('id')
            ->addIdentifier('event', null, ['label' => 'Событие'])
            ->add(
                'user',
                'string',
                [
                    'template' => 'Admin:user_link_field.html.twig',
                    'label' => 'Пользователь',
                ]
            )
            ->add('user.email', 'string', ['label' => 'E-Mail'])
            ->add('user.phone', 'string', ['label' => 'Тел.'])
            ->add(
                'amount',
                MoneyType::class,
                [
                    'currency' => 'UAH',
                    'label' => 'Цена',
                ]
            )
            ->add(
                'amountWithoutDiscount',
                MoneyType::class,
                [<commit_msg>Fix ticket list user.<commit_after><?php

namespace App\Admin;

use App\Entity\Payment;
use App\Repository\EventRepository;
use Doctrine\Common\Collections\Criteria;
use Sonata\AdminBundle\Admin\AbstractAdmin;
use Sonata\AdminBundle\Datagrid\DatagridMapper;
use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Form\FormMapper;
use Sonata\AdminBundle\Route\RouteCollection;
use Sonata\AdminBundle\Show\ShowMapper;
use Sonata\Form\Type\DateTimePickerType;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\MoneyType;
use Symfony\Component\Form\Extension\Core\Type\TextType;

/**
 * Class TicketAdmin.
 */
final class TicketAdmin extends AbstractAdmin
{
    /** @var EventRepository */
    private $eventRepository;

    /**
     * Default Datagrid values.
     *
     * @var array
     */
    protected $datagridValues =
        [
            '_page' => 1,
            '_sort_order' => 'DESC',
            '_sort_by' => 'id',
        ];

    /**
     * @param string          $code
     * @param string          $class
     * @param string          $baseControllerName
     * @param EventRepository $eventRepository
     */
    public function __construct($code, $class, $baseControllerName, EventRepository $eventRepository)
    {
        parent::__construct($code, $class, $baseControllerName);
        $this->eventRepository = $eventRepository;
    }

    /**
     * @return array
     */
    public function getExportFields(): array
    {
        return [
            'id',
            'event',
            'user.fullname',
            'user.email',
            'user.phone',
            'amount',
            'amountWithoutDiscount',
            'payment',
            'createdAt',
            'updatedAt',
            'used',
        ];
    }

    /**
     * @param RouteCollection $collection
     */
    protected function configureRoutes(RouteCollection $collection): void
    {
        $collection->remove('create');
        $collection->add('remove_paid_ticket_from_payment', $this->getRouterIdParameter().'/remove_paid_ticket_from_payment');
        $collection->add('download', $this->getRouterIdParameter().'/download');
    }

    /**
     * @param ListMapper $listMapper
     */
    protected function configureListFields(ListMapper $listMapper): void
    {
        $listMapper
            ->addIdentifier('id')
            ->addIdentifier('event', null, ['label' => 'Событие'])
            ->add(
                'user',
                'string',
                [
                    'template' => 'Admin/user_link_field.html.twig',
                    'label' => 'Пользователь',
                ]
            )
            ->add('user.email', 'string', ['label' => 'E-Mail'])
            ->add('user.phone', 'string', ['label' => 'Тел.'])
            ->add(
                'amount',
                MoneyType::class,
                [
                    'currency' => 'UAH',
                    'label' => 'Цена',
                ]
            )
            ->add(
                'amountWithoutDiscount',
                MoneyType::class,
                [
{'fraction_non_alphanumeric': 0.13044159098026933, 'fraction_numerical': 0.00031318509238960227, 'mean_word_length': 1.9005449591280654, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 49, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6855511', 'n_tokens_mistral': 1778, 'n_tokens_neox': 1731, 'n_words': 301}