Symfony\Component\Form\Form::__construct PHP Метод

__construct() публичный Метод

public __construct ( $name, Symfony\Component\EventDispatcher\EventDispatcherInterface $dispatcher, array $types = [], array $clientTransformers = [], array $normTransformers = [], Symfony\Component\Form\DataMapperInterface $dataMapper = null, array $validators = [], $required = false, $readOnly = false, $errorBubbling = false, $emptyData = null, array $attributes = [] )
$dispatcher Symfony\Component\EventDispatcher\EventDispatcherInterface
$types array
$clientTransformers array
$normTransformers array
$dataMapper Symfony\Component\Form\DataMapperInterface
$validators array
$attributes array
    public function __construct($name, EventDispatcherInterface $dispatcher,
        array $types = array(), array $clientTransformers = array(),
        array $normTransformers = array(),
        DataMapperInterface $dataMapper = null, array $validators = array(),
        $required = false, $readOnly = false, $errorBubbling = false,
        $emptyData = null, array $attributes = array())
    {
        foreach ($clientTransformers as $transformer) {
            if (!$transformer instanceof DataTransformerInterface) {
                throw new UnexpectedTypeException($transformer, 'Symfony\Component\Form\DataTransformerInterface');
            }
        }

        foreach ($normTransformers as $transformer) {
            if (!$transformer instanceof DataTransformerInterface) {
                throw new UnexpectedTypeException($transformer, 'Symfony\Component\Form\DataTransformerInterface');
            }
        }

        foreach ($validators as $validator) {
            if (!$validator instanceof FormValidatorInterface) {
                throw new UnexpectedTypeException($validator, 'Symfony\Component\Form\FormValidatorInterface');
            }
        }

        $this->name = (string) $name;
        $this->dispatcher = $dispatcher;
        $this->types = $types;
        $this->clientTransformers = $clientTransformers;
        $this->normTransformers = $normTransformers;
        $this->dataMapper = $dataMapper;
        $this->validators = $validators;
        $this->required = (Boolean) $required;
        $this->readOnly = (Boolean) $readOnly;
        $this->errorBubbling = (Boolean) $errorBubbling;
        $this->emptyData = $emptyData;
        $this->attributes = $attributes;

        $this->setData(null);
    }

Usage Example

Пример #1
0
 /**
  * {@inheritDoc}
  */
 public function __construct($key, array $options = array())
 {
     // Override parent option
     // \DateTime objects are never edited by reference, because
     // we treat them like value objects
     $this->addOption('by_reference', false);
     parent::__construct($key, $options);
 }
All Usage Examples Of Symfony\Component\Form\Form::__construct