Exemplo n.º 1
0
 /**
  * @param string|FormTypeInterface|ResourceInterface $type
  * @param mixed                                      $data
  * @param mixed[]                                    $options
  *
  * @return FormInterface
  */
 public function create($type = null, $data = null, array $options = [])
 {
     if ($type instanceof ResourceInterface) {
         $type = $this->parameterResolver->resolveForm($type);
     }
     $validationGroups = $this->parameterResolver->resolveValidationGroups();
     $translationDomain = $this->parameterResolver->resolveTranslationDomain();
     if (!empty($validationGroups)) {
         $options['validation_groups'] = $validationGroups;
     }
     if (!empty($translationDomain)) {
         $options['translation_domain'] = $translationDomain;
     }
     if ($this->parameterResolver->resolveApi()) {
         $options['csrf_protection'] = false;
     }
     return $this->factory->create($type, $data, $options);
 }
Exemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 public function resolveForm(ResourceInterface $resource)
 {
     return !isset($this->cache[$key = 'form_' . spl_object_hash($resource)]) ? $this->cache[$key] = $this->parameterResolver->resolveForm($resource) : $this->cache[$key];
 }