Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace Admingenerated\AppBundle\Form\BasePaymentType;
- use Admingenerator\GeneratorBundle\Form\BaseType;
- use Admingenerator\GeneratorBundle\Form\BaseOptions;
- use Symfony\Component\Form\FormBuilderInterface;
- use JMS\SecurityExtraBundle\Security\Authorization\Expression\Expression;
- class FiltersType extends BaseType
- {
- protected $securityContext;
- public function buildForm(FormBuilderInterface $builder, array $options)
- {
- $this->groups = $options['groups'];
- if ($this->canDisplayUnit()) {
- $builder->add('unit', $this->getTypeUnit(), $this->getOptionsUnit($options));
- }
- if ($this->canDisplayEstimate()) {
- $builder->add('estimate', $this->getTypeEstimate(), $this->getOptionsEstimate($options));
- }
- }
- /**
- * Get form type for unit field.
- *
- * @return string|FormTypeInterface Field form type.
- */
- protected function getTypeUnit()
- {
- return $this->inject('s2a_select2_entity');
- }
- /**
- * Get options for unit field.
- *
- * @param array $builderOptions The builder options.
- * @return array Field options.
- */
- protected function getOptionsUnit(array $builderOptions = array())
- {
- $optionsClass = '\AppBundle\Form\Type\Payment\Options';
- $options = class_exists($optionsClass) ? new $optionsClass() : null;
- return $this->resolveOptions('unit', array( 'label' => 'Отдел', 'translation_domain' => 'Admin', 'required' => false, 'multiple' => false, 'em' => 'default', 'class' => 'AppBundle\\Entity\\Unit',), $builderOptions, $options
- );
- }
- /**
- * Check filters groups for unit field.
- *
- * @return boolean
- */
- protected function canDisplayUnit()
- {
- return $this->checkGroups(array());
- }
- /**
- * Get form type for estimate field.
- *
- * @return string|FormTypeInterface Field form type.
- */
- protected function getTypeEstimate()
- {
- return $this->inject('s2a_select2_entity');
- }
- /**
- * Get options for estimate field.
- *
- * @param array $builderOptions The builder options.
- * @return array Field options.
- */
- protected function getOptionsEstimate(array $builderOptions = array())
- {
- $optionsClass = '\AppBundle\Form\Type\Payment\Options';
- $options = class_exists($optionsClass) ? new $optionsClass() : null;
- return $this->resolveOptions('estimate', array( 'label' => 'Статья', 'translation_domain' => 'Admin', 'required' => false, 'multiple' => false, 'em' => 'default', 'class' => 'AppBundle\\Entity\\Estimate',), $builderOptions, $options
- );
- }
- /**
- * Check filters groups for estimate field.
- *
- * @return boolean
- */
- protected function canDisplayEstimate()
- {
- return $this->checkGroups(array());
- }
- public function getName()
- {
- return 'filters_appbundle_payment';
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement