Advertisement
Guest User

Untitled

a guest
May 11th, 2015
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.25 KB | None | 0 0
  1. <?php
  2.  
  3. namespace Admingenerated\AppBundle\Form\BasePaymentType;
  4.  
  5. use Admingenerator\GeneratorBundle\Form\BaseType;
  6. use Admingenerator\GeneratorBundle\Form\BaseOptions;
  7. use Symfony\Component\Form\FormBuilderInterface;
  8. use JMS\SecurityExtraBundle\Security\Authorization\Expression\Expression;
  9.  
  10. class FiltersType extends BaseType
  11. {
  12.     protected $securityContext;
  13.  
  14.     public function buildForm(FormBuilderInterface $builder, array $options)
  15.     {
  16.         $this->groups = $options['groups'];
  17.  
  18.             if ($this->canDisplayUnit()) {
  19.             $builder->add('unit', $this->getTypeUnit(), $this->getOptionsUnit($options));
  20.         }
  21.             if ($this->canDisplayEstimate()) {
  22.             $builder->add('estimate', $this->getTypeEstimate(), $this->getOptionsEstimate($options));
  23.         }
  24.         }
  25.  
  26.             /**
  27.         * Get form type for unit field.
  28.         *
  29.         * @return string|FormTypeInterface Field form type.
  30.         */
  31.         protected function getTypeUnit()
  32.         {
  33.         return $this->inject('s2a_select2_entity');
  34.         }
  35.  
  36.         /**
  37.         * Get options for unit field.
  38.         *
  39.         * @param  array $builderOptions The builder options.
  40.         * @return array Field options.
  41.         */
  42.         protected function getOptionsUnit(array $builderOptions = array())
  43.         {
  44.             $optionsClass = '\AppBundle\Form\Type\Payment\Options';
  45.             $options = class_exists($optionsClass) ? new $optionsClass() : null;
  46.  
  47.             return $this->resolveOptions('unit', array(  'label' => 'Отдел',  'translation_domain' => 'Admin',  'required' => false,  'multiple' => false,  'em' => 'default',  'class' => 'AppBundle\\Entity\\Unit',), $builderOptions, $options
  48.             );
  49.         }
  50.  
  51.         /**
  52.         * Check filters groups for unit field.
  53.         *
  54.         * @return boolean
  55.         */
  56.         protected function canDisplayUnit()
  57.         {
  58.             return $this->checkGroups(array());
  59.         }
  60.             /**
  61.         * Get form type for estimate field.
  62.         *
  63.         * @return string|FormTypeInterface Field form type.
  64.         */
  65.         protected function getTypeEstimate()
  66.         {
  67.         return $this->inject('s2a_select2_entity');
  68.         }
  69.  
  70.         /**
  71.         * Get options for estimate field.
  72.         *
  73.         * @param  array $builderOptions The builder options.
  74.         * @return array Field options.
  75.         */
  76.         protected function getOptionsEstimate(array $builderOptions = array())
  77.         {
  78.             $optionsClass = '\AppBundle\Form\Type\Payment\Options';
  79.             $options = class_exists($optionsClass) ? new $optionsClass() : null;
  80.  
  81.             return $this->resolveOptions('estimate', array(  'label' => 'Статья',  'translation_domain' => 'Admin',  'required' => false,  'multiple' => false,  'em' => 'default',  'class' => 'AppBundle\\Entity\\Estimate',), $builderOptions, $options
  82.             );
  83.         }
  84.  
  85.         /**
  86.         * Check filters groups for estimate field.
  87.         *
  88.         * @return boolean
  89.         */
  90.         protected function canDisplayEstimate()
  91.         {
  92.             return $this->checkGroups(array());
  93.         }
  94.    
  95.     public function getName()
  96.     {
  97.         return 'filters_appbundle_payment';
  98.     }
  99. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement