<commit_before><?php

/*
 * Fichier créer par : <NAME> <<EMAIL>>
 */

namespace WBB\BarBundle\Controller\Admin;

use WBB\BarBundle\Entity\Bar;
use WBB\CoreBundle\Controller\Admin\Admin;
use Sonata\AdminBundle\Form\FormMapper;
use Sonata\AdminBundle\Datagrid\DatagridMapper;
use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Show\ShowMapper;

class BarAdmin extends Admin
{

    /**
     * {@inheritdoc}
     */
    protected function configureListFields(ListMapper $listMapper)
    {
        $listMapper
            ->addIdentifier('name')
            ->add('isCreditCard', null, array('editable' => true))
            ->add('isCoatCheck', null, array('editable' => true))
            ->add('price', null, array('editable' => true))
            ->add('isReservation', null, array('editable' => true))
            ->add('onTop', null, array('editable' => true))
            ->add('status', null, array('editable' => true))
        ;
    }

    /**
     * {@inheritdoc}
     */
    protected function configureDatagridFilters(DatagridMapper $filterMapper)
    {
        $filterMapper
            ->add('id')
            ->add('name')
            ->add('phone')
            ->add('email')
            ->add('website')
            ->add('twitter')
            ->add('facebook')
            ->add('instagram')
            ->add('isCreditCard')
            ->add('isCoatCheck')
            ->add('price')
            ->add('isReservation')
            ->add('onTop')
            ->add('status')
        ;
    }

    /**
     * {@inheritdoc}
     */
    protected function configureShowFields(ShowMapper $showMapper)
    {
        $showMapper
            ->with('General')
                ->add('id')
                ->add('name')
                ->add('latitude')
                ->add('langitude')
                ->add('address')
                ->add('phone')
                ->add('email')
                ->add('website')
                ->add('twitter')
                ->add('facebook')
                ->add('instagram')
                ->add('isCreditCard')
                ->add('isCoatCheck')
                ->add('parking')
                ->add('price')
                ->add('menu')
                ->add('isReservation')
                ->add('reservation')
                ->add('description')
                ->add('onTop')
                ->add('status')
            ->end()
        ;
    }

    /**
     * {@inheritdoc}
     */
    protected function configureFormFields(FormMapper $formMapper)
    {
        $this->getSubject()->setUser($this->getUser());

        $formMapper
            ->with('General')
                ->add('user', 'sonata_type_model')
                ->add('name')
                ->add('city', 'sonata_type_model')
                ->add('latitude')
                ->add('longitude')
                ->add('address')
                ->add('phone')
                ->add('email')
                ->add('website')
            ->end()
            ->with('Social')
                ->add('twitter')
                ->add('facebook')
                ->add('instagram')
            ->end()
            ->with('Details')
                ->add('isCreditCard')
                ->add('isCoatCheck')
                ->add('parking')
                ->add('parking', 'choice', array(
                    'required' => false,
                    'choices'  => array(
                        1 => 'Oui',
                        0 => 'Non'
                    )
                ))
                ->add('price', 'choice', array(
                    'required' => false,
                    'choices'  => array(
                        1 => 1,
                        2 => 2,
                        3 => 3,
                        4 => 4
                    )
                ))
                ->add('menu')
                ->add('isReservation')
                ->add('reservation')
                ->add('description')
            ->end()
            ->with('Medias')
                ->add('medias', 'sonata_type_collection', array('required' => false),
                    array(
                        'edit' => 'inline',
                        'inline' => 'table',
                        'sortable'  => 'position'
                    ))
            ->end()
            ->with('Order')
                ->add('onTop')
                ->add('status', 'choice', array(
                    'required' => false,
                    'choices'  => array(
                        Bar::BAR_STATUS_PENDING_VALUE  =>  Bar::BAR_STATUS_PENDING_TEXT,
                        Bar::BAR_STATUS_ENABLED_VALUE  =>  Bar::BAR_STATUS_ENABLED_TEXT,
                        Bar::BAR_STATUS_DISABLED_VALUE =>  Bar::BAR_STATUS_DISABLED_TEXT
                    )
                ))
                ->add('openings', 'sonata_type_collection', array('required' => false),
                    array(
                        'edit' => 'inline',
                        'inline' => 'table'
                    ))
            ->end()
        ;
    }

    /**
     * {@inheritdoc}
     */
    public function getExportFields()
    {
        return array(
            $this->trans($this->getLabelTranslatorStrategy()->getLabel('username', 'show', 'label'))  => 'username',
            $this->trans($this->getLabelTranslatorStrategy()->getLabel('firstname', 'show', 'label')) => 'firstname',
            $this->trans($this->getLabelTranslatorStrategy()->getLabel('lastname', 'show', 'label'))  => 'lastname',
            $this->trans($this->getLabelTranslatorStrategy()->getLabel('email', 'show', 'label'))     => 'email',
        );
    }

    public function prePersist($object)
    {
        foreach ($object->getMedias() as $media) {
            $media->setBar($object);
        }
        foreach ($object->getOpenings() as $opening) {
            $opening->setBar($object);
        }<commit_msg>Bar opening in own onglet<commit_after><?php

/*
 * Fichier créer par : <NAME> <<EMAIL>>
 */

namespace WBB\BarBundle\Controller\Admin;

use WBB\BarBundle\Entity\Bar;
use WBB\CoreBundle\Controller\Admin\Admin;
use Sonata\AdminBundle\Form\FormMapper;
use Sonata\AdminBundle\Datagrid\DatagridMapper;
use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Show\ShowMapper;

class BarAdmin extends Admin
{

    /**
     * {@inheritdoc}
     */
    protected function configureListFields(ListMapper $listMapper)
    {
        $listMapper
            ->addIdentifier('name')
            ->add('isCreditCard', null, array('editable' => true))
            ->add('isCoatCheck', null, array('editable' => true))
            ->add('price', null, array('editable' => true))
            ->add('isReservation', null, array('editable' => true))
            ->add('onTop', null, array('editable' => true))
            ->add('status', null, array('editable' => true))
        ;
    }

    /**
     * {@inheritdoc}
     */
    protected function configureDatagridFilters(DatagridMapper $filterMapper)
    {
        $filterMapper
            ->add('id')
            ->add('name')
            ->add('phone')
            ->add('email')
            ->add('website')
            ->add('twitter')
            ->add('facebook')
            ->add('instagram')
            ->add('isCreditCard')
            ->add('isCoatCheck')
            ->add('price')
            ->add('isReservation')
            ->add('onTop')
            ->add('status')
        ;
    }

    /**
     * {@inheritdoc}
     */
    protected function configureShowFields(ShowMapper $showMapper)
    {
        $showMapper
            ->with('General')
                ->add('id')
                ->add('name')
                ->add('latitude')
                ->add('langitude')
                ->add('address')
                ->add('phone')
                ->add('email')
                ->add('website')
                ->add('twitter')
                ->add('facebook')
                ->add('instagram')
                ->add('isCreditCard')
                ->add('isCoatCheck')
                ->add('parking')
                ->add('price')
                ->add('menu')
                ->add('isReservation')
                ->add('reservation')
                ->add('description')
                ->add('onTop')
                ->add('status')
            ->end()
        ;
    }

    /**
     * {@inheritdoc}
     */
    protected function configureFormFields(FormMapper $formMapper)
    {
        $this->getSubject()->setUser($this->getUser());

        $formMapper
            ->with('General')
                ->add('user', 'sonata_type_model')
                ->add('name')
                ->add('city', 'sonata_type_model')
                ->add('latitude')
                ->add('longitude')
                ->add('address')
                ->add('phone')
                ->add('email')
                ->add('website')
            ->end()
            ->with('Social')
                ->add('twitter')
                ->add('facebook')
                ->add('instagram')
            ->end()
            ->with('Details')
                ->add('isCreditCard')
                ->add('isCoatCheck')
                ->add('parking')
                ->add('parking', 'choice', array(
                    'required' => false,
                    'choices'  => array(
                        1 => 'Oui',
                        0 => 'Non'
                    )
                ))
                ->add('price', 'choice', array(
                    'required' => false,
                    'choices'  => array(
                        1 => 1,
                        2 => 2,
                        3 => 3,
                        4 => 4
                    )
                ))
                ->add('menu')
                ->add('isReservation')
                ->add('reservation')
                ->add('description')
            ->end()
            ->with('Medias')
                ->add('medias', 'sonata_type_collection', array('required' => false),
                    array(
                        'edit' => 'inline',
                        'inline' => 'table',
                        'sortable'  => 'position'
                    ))
            ->end()
            ->with('Order')
                ->add('onTop')
                ->add('status', 'choice', array(
                    'required' => false,
                    'choices'  => array(
                        Bar::BAR_STATUS_PENDING_VALUE  =>  Bar::BAR_STATUS_PENDING_TEXT,
                        Bar::BAR_STATUS_ENABLED_VALUE  =>  Bar::BAR_STATUS_ENABLED_TEXT,
                        Bar::BAR_STATUS_DISABLED_VALUE =>  Bar::BAR_STATUS_DISABLED_TEXT
                    )
                ))
            ->end()
            ->with('Openings')
                ->add('openings', 'sonata_type_collection', array('required' => false),
                    array(
                        'edit' => 'inline',
                        'inline' => 'table'
                    ))
            ->end()
        ;
    }

    /**
     * {@inheritdoc}
     */
    public function getExportFields()
    {
        return array(
            $this->trans($this->getLabelTranslatorStrategy()->getLabel('username', 'show', 'label'))  => 'username',
            $this->trans($this->getLabelTranslatorStrategy()->getLabel('firstname', 'show', 'label')) => 'firstname',
            $this->trans($this->getLabelTranslatorStrategy()->getLabel('lastname', 'show', 'label'))  => 'lastname',
            $this->trans($this->getLabelTranslatorStrategy()->getLabel('email', 'show', 'label'))     => 'email',
        );
    }

    public function prePersist($object)
    {
        foreach ($object->getMedias() as $media) {
            $media->setBar($object);
        }
        foreach ($object->getOpenings() as $opening) {
            $opening->setBar($object);
        }
{'fraction_non_alphanumeric': 0.16132559508789637, 'fraction_numerical': 0.001682227268904029, 'mean_word_length': 1.28785837983452, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 271, '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': '3513356', 'n_tokens_mistral': 3248, 'n_tokens_neox': 3062, 'n_words': 480}