<?php

namespace Site\BackendBundle\Admin;

use Sonata\AdminBundle\Admin\Admin;
use Sonata\AdminBundle\Form\FormMapper;
use Sonata\AdminBundle\Datagrid\DatagridMapper;
use Sonata\AdminBundle\Datagrid\ListMapper;


class UsersAdmin extends Admin
{
    protected function configureListFields(ListMapper $listMapper)
    {
        $listMapper
            ->addIdentifier('id')
            ->addIdentifier('email')
            ->add('firstName')
            ->add('lastName')
            ->add('note', null, array('label' => 'Note (Admin can write notes/comments about the user in this field)'))
            ->addIdentifier('active', null, array('label' => 'Active / Not Active'))
        ;
    }

    protected function configureDatagridFilters(DatagridMapper $datagridMapper)
    {
        $datagridMapper
            ->add('email')
            ->add('firstname', null, array('label' => 'First Name'))
            ->add('lastname', null, array('label' => 'Last Name'))
            ->add('active', null, array('label' => 'Active / Not Active'))
        ;
    }

    protected function configureFormFields(FormMapper $formMapper)
    {
        $formMapper
            ->add('email')
            ->add('password', null, array('label' => 'Password (Has to be codified with algorithm SHA-512 base 64)'))
            ->add('firstname')
            ->add('lastname')
            ->add('note', null, array('required' => false))
            ->add('active', null, array('required' => false))
        ;
    }
}
?>