<commit_before><?php

namespace NS\ApiBundle\Admin;

use Sonata\AdminBundle\Admin\Admin;
use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Form\FormMapper;
use Sonata\AdminBundle\Show\ShowMapper;

/**
 * Description of ClientAdmin
 *
 * @author gnat
 */
class ClientAdmin extends Admin
{
    /**
     * @param FormMapper $formMapper
     */
    protected function configureFormFields(FormMapper $formMapper)
    {
        $formMapper
            ->add('name')
            ->add('redirectUris',       'TextToArray')
            ->add('allowedGrantTypes',  'OAuthGrantTypes')
        ;
    }

    /**
     * @param ListMapper $listMapper
     */
    protected function configureListFields(ListMapper $listMapper)
    {
        $listMapper
            ->add('name')
            ->add('publicId',null,array('label'=>'Client Id'))
            ->add('secret',null,array('label'=>'Client Secret'))
            ->add('_action', 'actions', array(
                'actions' => array(
                    'show' => array(),
                    'edit' => array(),
                    'delete' => array(),
                )
            ))
        ;
    }

    /**
     * @param ShowMapper $showMapper
     */
    protected function configureShowFields(ShowMapper $showMapper)
    {
        $showMapper
            ->add('name')
            ->add('publicId',null,array('label'=>'Client Id'))
            ->add('secret',null,array('label'=>'Client Secret'))
            ->add('redirectUris')
            ->add('allowedGrantTypes')
        ;
    }
}<commit_msg>Admin Client User admin form<commit_after><?php

namespace NS\ApiBundle\Admin;

use Sonata\AdminBundle\Admin\Admin;
use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Form\FormMapper;
use Sonata\AdminBundle\Show\ShowMapper;
use NS\SentinelBundle\Form\Types\Role;

/**
 * Description of ClientAdmin
 *
 * @author gnat
 */
class ClientAdmin extends Admin
{
    /**
     * @param FormMapper $formMapper
     */
    protected function configureFormFields(FormMapper $formMapper)
    {
        $formMapper
            ->add('name')
            ->add('redirectUris',       'TextToArray')
            ->add('allowedGrantTypes',  'OAuthGrantTypes')
            ->add('user',null,array('empty_value'=>'Please Select', 'query_builder'=>function(\Doctrine\ORM\EntityRepository $repo){
                                                return $repo->createQueryBuilder('u')
                                                            ->leftJoin('u.acls','a')
                                                            ->addSelect('a')
                                                            ->where('a.type IN (:apiType)')
                                                            ->setParameter('apiType',array(Role::REGION_API,Role::COUNTRY_API,Role::SITE_API));
            }))
        ;
    }

    /**
     * @param ListMapper $listMapper
     */
    protected function configureListFields(ListMapper $listMapper)
    {
        $listMapper
            ->add('name')
            ->add('publicId',null,array('label'=>'Client Id'))
            ->add('secret',null,array('label'=>'Client Secret'))
            ->add('user')
            ->add('_action', 'actions', array(
                'actions' => array(
                    'show' => array(),
                    'edit' => array(),
                    'delete' => array(),
                )
            ))
        ;
    }

    /**
     * @param ShowMapper $showMapper
     */
    protected function configureShowFields(ShowMapper $showMapper)
    {
        $showMapper
            ->add('name')
            ->add('publicId',null,array('label'=>'Client Id'))
            ->add('secret',null,array('label'=>'Client Secret'))
            ->add('redirectUris')
            ->add('allowedGrantTypes')
        ;
    }
}
{'fraction_non_alphanumeric': 0.14412301277039355, 'fraction_numerical': 0.0, 'mean_word_length': 1.716206652512385, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 52, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '510945', 'n_tokens_mistral': 1003, 'n_tokens_neox': 992, 'n_words': 163}