<?php

/**
 *
 * @class TokenType
 * @author sb
 *
 * LICENSE: This Software is the property of Lifestyle Webconsulting GmbH (Aschaffenburg, Germany)
 * and is protected by copyright law - it is NOT Freeware.
 *
 * Any unauthorized use of this software without a valid license
 * is a violation of the license agreement and will be prosecuted by
 * civil and criminal law.
 *
 * @copyright  2015 Lifestyle Webconsulting GmbH
 * @version    $Id:$
 * @link       http://www.life-style.de
 *
 */

namespace Sso\BackendBundle\Form;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\Extension\Core\Type;

/**
 * Class WsObjectType
 * @package Sso\BackendBundle\Form
 */
class WsObjectType extends AbstractType
{
    /**
     * @param FormBuilderInterface $builder
     * @param array $options
     */
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder->add('type', EntityType::class, array(
            'class' => 'Sso\Webservices\ObjectBundle\Entity\Type',
            'choice_label' => 'name',
            'required' => true,
            'label' => "Object Type"
        ))
            ->add('parent', EntityType::class, array(
                'class' => 'Sso\Webservices\ObjectBundle\Entity\Object',
                'choice_label' => 'name',
                'required' => false,
                'label' => "Parent"
            ))
            ->add('name', Type\TextType::class)
            ->add('referenceId', Type\TextType::class)
            ->add('active', Type\TextType::class);
    }

    /**
     * @param OptionsResolver $resolver
     */
    public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefaults(array(
            'data_class' => 'Sso\Webservices\ObjectBundle\Entity\Object'
        ));
    }

    /**
     *
     * @return string
     */
    public function getName()
    {
        return 'sso_backendbundle_object';
    }

}
