<commit_before><?php
/**
 * Created by JetBrains PhpStorm.
 * User: Nursultan
 * Date: 4/1/13
 * Time: 12:39 PM
 * To change this template use File | Settings | File Templates.
 */
namespace Nurix\CatalogBundle\Admin;
use Doctrine\ORM\EntityRepository;
use Sonata\AdminBundle\Admin\Admin;
use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Form\FormMapper;
use Sonata\AdminBundle\Show\ShowMapper;

class GoodsAdmin extends Admin {

    protected function configureShowField(ShowMapper $showmapper)
    {
        $showmapper
                ->add('id',null,array('label'=>'ID'))
                ->add('name',null,array('label'=>'Название'))
                ->add('catalog','sonata_type_collection',array('label'=>'Каталог'))
                ->add('short_description',null,array('label'=>'Краткое описание'))
                ->add('full_desctiption',null,array('label'=>'Полное описание'))
                ->add('price',null,array('label'=>'Цена'))
                ->add('imagePath','sonata_media_type',array('label'=>'Галерея','provider'=>'sonata.media.provider.image','context'=>'goods'))
                ->add('youtube','sonata_media_type',array('label'=>'Youtube','provider'=>'sonata.media.provider.youtube','context'=>'youtube'))
                ->add('active',null,array('label'=>'Активен'))
                ->add('amount',null,array('label'=>'Количество'))
                ->add('characteristic',null,array('label'=>'Характеристика'));
    }

    protected function configureFormFields(FormMapper $formmapper)
    {
        $formmapper
                ->add('name',null,array('label'=>'Название'))
                ->add('catalog','entity', array('label'=>'Подкатегория',
                    'class' => 'CatalogBundle:Catalog','required'=>true,
                    'query_builder' => function(EntityRepository $er) {
                        return $er->createQueryBuilder('p')
                            ->where('p.parent is not null');},
                        ))
                ->add('short_description','textarea',array('label'=>'Краткое описание','required'=>false))
                ->add('full_desctiption','textarea',array('label'=>'Полное описание','required'=>false))
                ->add('price',null,array('label'=>'Цена'))
                ->add('imagePath', 'sonata_type_model_list', array('required'=>false,'label'=>'Галерея'), array('link_parameters' => array('context' => 'goods')))
                ->add('youtube','sonata_type_model_list',array('required'=>false,'label'=>'Youtube'), array('link_parameters'=>array('context'=>'youtube')))
                ->add('active',null,array('label'=>'Активен'))
                ->add('amount',null,array('label'=>'Количество'))
                ->add('review','ckeditor',array('label'=>'Обзор'));
    }

    protected function configureListFields(ListMapper $listmapper)
    {
        $listmapper
                ->add('id',null,array('label'=>'ID'))
                ->addIdentifier('name',null,array('label'=>'Название'))
                ->add('catalog','sonata_type_model',array('label'=>'Подкатегория'))
                ->add('price',null,array('label'=>'Цена'))
                ->add('active',null,array('label'=>'Активен'))
                ->add('amount',null,array('label'=>'Количество'));
    }


    public function getTemplate($name)
    {
        switch ($name) {
            case 'list':
                return 'CatalogBundle:Admin:goods_list.html.twig';
                break;<commit_msg>NUR-24 Changed admin interface default gallery context to default<commit_after><?php
/**
 * Created by JetBrains PhpStorm.
 * User: Nursultan
 * Date: 4/1/13
 * Time: 12:39 PM
 * To change this template use File | Settings | File Templates.
 */
namespace Nurix\CatalogBundle\Admin;
use Doctrine\ORM\EntityRepository;
use Sonata\AdminBundle\Admin\Admin;
use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Form\FormMapper;
use Sonata\AdminBundle\Show\ShowMapper;

class GoodsAdmin extends Admin {

    protected function configureShowField(ShowMapper $showmapper)
    {
        $showmapper
                ->add('id',null,array('label'=>'ID'))
                ->add('name',null,array('label'=>'Название'))
                ->add('catalog','sonata_type_collection',array('label'=>'Каталог'))
                ->add('short_description',null,array('label'=>'Краткое описание'))
                ->add('full_desctiption',null,array('label'=>'Полное описание'))
                ->add('price',null,array('label'=>'Цена'))
                ->add('imagePath','sonata_media_type',array('label'=>'Галерея','provider'=>'sonata.media.provider.image','context'=>'default'))
                ->add('youtube','sonata_media_type',array('label'=>'Youtube','provider'=>'sonata.media.provider.youtube','context'=>'default'))
                ->add('active',null,array('label'=>'Активен'))
                ->add('amount',null,array('label'=>'Количество'))
                ->add('characteristic',null,array('label'=>'Характеристика'));
    }

    protected function configureFormFields(FormMapper $formmapper)
    {
        $formmapper
                ->add('name',null,array('label'=>'Название'))
                ->add('catalog','entity', array('label'=>'Подкатегория',
                    'class' => 'CatalogBundle:Catalog','required'=>true,
                    'query_builder' => function(EntityRepository $er) {
                        return $er->createQueryBuilder('p')
                            ->where('p.parent is not null');},
                        ))
                ->add('short_description','textarea',array('label'=>'Краткое описание','required'=>false))
                ->add('full_desctiption','textarea',array('label'=>'Полное описание','required'=>false))
                ->add('price',null,array('label'=>'Цена'))
                ->add('imagePath', 'sonata_type_model_list', array('required'=>false,'label'=>'Галерея'), array('link_parameters' => array('context' => 'default')))
                ->add('youtube','sonata_type_model_list',array('required'=>false,'label'=>'Youtube'), array('link_parameters'=>array('context'=>'default')))
                ->add('active',null,array('label'=>'Активен'))
                ->add('amount',null,array('label'=>'Количество'))
                ->add('review','ckeditor',array('label'=>'Обзор'));
    }

    protected function configureListFields(ListMapper $listmapper)
    {
        $listmapper
                ->add('id',null,array('label'=>'ID'))
                ->addIdentifier('name',null,array('label'=>'Название'))
                ->add('catalog','sonata_type_model',array('label'=>'Подкатегория'))
                ->add('price',null,array('label'=>'Цена'))
                ->add('active',null,array('label'=>'Активен'))
                ->add('amount',null,array('label'=>'Количество'));
    }


    public function getTemplate($name)
    {
        switch ($name) {
            case 'list':
                return 'CatalogBundle:Admin:goods_list.html.twig';
                break;
{'fraction_non_alphanumeric': 0.1892470051340559, 'fraction_numerical': 0.002567027952082145, 'mean_word_length': 2.989192263936291, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 145, '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': '3097166', 'n_tokens_mistral': 2004, 'n_tokens_neox': 2047, 'n_words': 229}