<?php

namespace OfficeBrain\Bundle\UserBundle\Form;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\Validator\Constraints as Assert;
use Doctrine\ORM\EntityRepository;

class AssignServiceGroupType extends AbstractType
{	
	/**
	 *
	 * @param ContainerInterface $container
	 * @param $mode
	 */
	public function __construct(ContainerInterface $container, $countryId, $serviceGroupId)
	{
		$this->container=$container;
		$this->countryId = $countryId;
		$this->serviceGroupId = $serviceGroupId;
	}

    /**
     * @param FormBuilderInterface $builder
     * @param array $options
     */
    public function buildForm(FormBuilderInterface $builder, array $options)
    {	
    
    	$serviceGroupManager = $this->container->get('office_brain_service_group_manager');
    	$serviceGroup = $serviceGroupManager->getServiceGroup($this->countryId);
    	$builder->add('serviceGroup', 'choice', array(
    			'required' => true,
    			'empty_value' => 'Select Service Group',
    			'choices' => $serviceGroup,
    			'data'=>$this->serviceGroupId,
    			'constraints' => array(new Assert\NotBlank(array('message'=>'user.service_group.not_blank'))),
    	));    	
    }
    
    /**
     * @return string
     */
    public function getName()
    {
        return 'officebrain_bundle_userbundle_assign_service_group';
    }
}
