<commit_before><?php

namespace Application\Bundle\DefaultBundle\Admin;

use Application\Bundle\DefaultBundle\Admin\AbstractClass\AbstractTranslateAdmin;
use Application\Bundle\DefaultBundle\Entity\Event;
use Application\Bundle\DefaultBundle\Entity\Speaker;
use Application\Bundle\DefaultBundle\Form\Type\MyGedmoTranslationsType;
use Sonata\AdminBundle\Datagrid\DatagridMapper;
use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Form\FormMapper;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\HttpFoundation\File\File;

/**
 * Class SpeakerAdmin.
 */
class SpeakerAdmin extends AbstractTranslateAdmin
{
    /**
     * @var array
     */
    protected $datagridValues =
        [
            '_page' => 1,
            '_sort_order' => 'DESC',
            '_sort_by' => 'id',
        ];

    /**
     * {@inheritdoc}
     */
    public function postUpdate($object)
    {
        $this->prepareImageCache($object);
    }

    /**
     * {@inheritdoc}
     */
    public function postPersist($object)
    {
        $this->prepareImageCache($object);
    }

    /**
     * {@inheritdoc}
     */
    protected function configureFormFields(FormMapper $formMapper)
    {
        $localsRequiredService = $this->getConfigurationPool()->getContainer()->get('application.sonata.locales.required');
        $localOptions = $localsRequiredService->getLocalsRequiredArray();

        $eventFormOptions = [
            'class' => Event::class,
            'choice_label' => 'name',
            'multiple' => true,
            'expanded' => true,
            'label' => 'События',
        ];

        $formMapper
            ->with('Переводы')
                ->add('translations', MyGedmoTranslationsType::class, [
                        'translatable_class' => $this->getClass(),
                        'fields' => [
                            'name' => [
                                'label' => 'Имя',
                                'locale_options' => $localOptions,
                            ],
                            'about' => [
                                'label' => 'Описание',
                                'locale_options' => $localOptions,
                            ],
                        ],
                ])
            ->end()
            ->with('Общие')
                ->add('slug')
                ->add('email')
                ->add('company', null, ['label' => 'Место работы'])
                ->add('sortOrder', null, ['label' => 'Номер сортировки'])
                ->add('file', 'file', [
                    'required' => false,
                    'data_class' => File::class,
                    'property_path' => 'file',
                    'label' => 'Фото',
                ])
            ->end()
            ->with('Участвует в событиях', ['class' => 'col-md-3'])
                ->add('events', EntityType::class, $eventFormOptions)
            ->end()
            ->with('Кандидат на события', ['class' => 'col-md-3'])
                ->add('candidateEvents', EntityType::class, $eventFormOptions)
            ->end()
            ->with('Программный комитет', ['class' => 'col-md-3'])
                ->add('committeeEvents', EntityType::class, $eventFormOptions)
            ->end()
            ->with('Эксперт дискуссий', ['class' => 'col-md-3'])
                ->add('expertEvents', EntityType::class, $eventFormOptions)
            ->end()
        ;
    }

    /**
     * {@inheritdoc}
     */
    protected function configureDatagridFilters(DatagridMapper $filter)
    {
        $filter
            ->add('id')
            ->add('slug')
            ->add('name')
            ->add('events', null, ['label' => 'Участвует в событиях'])
            ->add('candidateEvents', null, ['label' => 'Кандидат на события'])
            ->add('committeeEvents', null, ['label' => 'Программный комитет'])
            ->add('expertEvents', null, ['label' => 'Программный комитет'])
        ;
    }

    /**
     * {@inheritdoc}
     */
    protected function configureListFields(ListMapper $listMapper)
    {
        $listMapper
            ->addIdentifier('slug')
            ->add('name', null, ['label' => 'Имя'])
        ;
    }

    /**
     * @param Speaker $speaker
     */
    private function prepareImageCache(Speaker $speaker)
    {
        $filter = 'speaker';
        $target = $speaker->getPhoto();
        if (empty($target)) {
            return;
        }
        $container = $this->getConfigurationPool()->getContainer();
        $cacheManager = $container->get('liip_imagine.cache.manager');<commit_msg>Fix typo<commit_after><?php

namespace Application\Bundle\DefaultBundle\Admin;

use Application\Bundle\DefaultBundle\Admin\AbstractClass\AbstractTranslateAdmin;
use Application\Bundle\DefaultBundle\Entity\Event;
use Application\Bundle\DefaultBundle\Entity\Speaker;
use Application\Bundle\DefaultBundle\Form\Type\MyGedmoTranslationsType;
use Sonata\AdminBundle\Datagrid\DatagridMapper;
use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Form\FormMapper;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\HttpFoundation\File\File;

/**
 * Class SpeakerAdmin.
 */
class SpeakerAdmin extends AbstractTranslateAdmin
{
    /**
     * @var array
     */
    protected $datagridValues =
        [
            '_page' => 1,
            '_sort_order' => 'DESC',
            '_sort_by' => 'id',
        ];

    /**
     * {@inheritdoc}
     */
    public function postUpdate($object)
    {
        $this->prepareImageCache($object);
    }

    /**
     * {@inheritdoc}
     */
    public function postPersist($object)
    {
        $this->prepareImageCache($object);
    }

    /**
     * {@inheritdoc}
     */
    protected function configureFormFields(FormMapper $formMapper)
    {
        $localsRequiredService = $this->getConfigurationPool()->getContainer()->get('application.sonata.locales.required');
        $localOptions = $localsRequiredService->getLocalsRequiredArray();

        $eventFormOptions = [
            'class' => Event::class,
            'choice_label' => 'name',
            'multiple' => true,
            'expanded' => true,
            'label' => 'События',
        ];

        $formMapper
            ->with('Переводы')
                ->add('translations', MyGedmoTranslationsType::class, [
                        'translatable_class' => $this->getClass(),
                        'fields' => [
                            'name' => [
                                'label' => 'Имя',
                                'locale_options' => $localOptions,
                            ],
                            'about' => [
                                'label' => 'Описание',
                                'locale_options' => $localOptions,
                            ],
                        ],
                ])
            ->end()
            ->with('Общие')
                ->add('slug')
                ->add('email')
                ->add('company', null, ['label' => 'Место работы'])
                ->add('sortOrder', null, ['label' => 'Номер сортировки'])
                ->add('file', 'file', [
                    'required' => false,
                    'data_class' => File::class,
                    'property_path' => 'file',
                    'label' => 'Фото',
                ])
            ->end()
            ->with('Участвует в событиях', ['class' => 'col-md-3'])
                ->add('events', EntityType::class, $eventFormOptions)
            ->end()
            ->with('Кандидат на события', ['class' => 'col-md-3'])
                ->add('candidateEvents', EntityType::class, $eventFormOptions)
            ->end()
            ->with('Программный комитет', ['class' => 'col-md-3'])
                ->add('committeeEvents', EntityType::class, $eventFormOptions)
            ->end()
            ->with('Эксперт дискуссий', ['class' => 'col-md-3'])
                ->add('expertEvents', EntityType::class, $eventFormOptions)
            ->end()
        ;
    }

    /**
     * {@inheritdoc}
     */
    protected function configureDatagridFilters(DatagridMapper $filter)
    {
        $filter
            ->add('id')
            ->add('slug')
            ->add('name')
            ->add('events', null, ['label' => 'Участвует в событиях'])
            ->add('candidateEvents', null, ['label' => 'Кандидат на события'])
            ->add('committeeEvents', null, ['label' => 'Программный комитет'])
            ->add('expertEvents', null, ['label' => 'Эксперт дискуссий'])
        ;
    }

    /**
     * {@inheritdoc}
     */
    protected function configureListFields(ListMapper $listMapper)
    {
        $listMapper
            ->addIdentifier('slug')
            ->add('name', null, ['label' => 'Имя'])
        ;
    }

    /**
     * @param Speaker $speaker
     */
    private function prepareImageCache(Speaker $speaker)
    {
        $filter = 'speaker';
        $target = $speaker->getPhoto();
        if (empty($target)) {
            return;
        }
        $container = $this->getConfigurationPool()->getContainer();
        $cacheManager = $container->get('liip_imagine.cache.manager');
{'fraction_non_alphanumeric': 0.15399673735725938, 'fraction_numerical': 0.001087547580206634, 'mean_word_length': 1.712684365781711, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 149, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5710409', 'n_tokens_mistral': 2604, 'n_tokens_neox': 2600, 'n_words': 406}