/** * @param ResolvedFormTypeInterface|null $formType * @param array &$types */ public static function typeAncestryForType(ResolvedFormTypeInterface $formType = null, array &$types) { if (!$formType instanceof ResolvedFormTypeInterface) { return; } $types[] = get_class($formType->getInnerType()); self::typeAncestryForType($formType->getParent(), $types); }
/** * Check if the parent type of the current type is allowed. * * @param string[] $types The class name of types * @param ResolvedFormTypeInterface $rType The resolved form type * * @return bool */ protected static function isType(array $types, ResolvedFormTypeInterface $rType = null) { if (null === $rType) { return false; } elseif (!in_array(get_class($rType->getInnerType()), $types)) { return static::isType($types, $rType->getParent()); } return true; }
public static function isType(ResolvedFormTypeInterface $type, $typeName) { do { if ($type->getName() === $typeName) { return true; } $type = $type->getParent(); } while ($type !== null); return false; }
/** * Returns the configured options resolver used for this type. * * @return \Symfony\Component\OptionsResolver\OptionsResolverInterface The options resolver. */ public function getOptionsResolver() { if (null === $this->optionsResolver) { if (null !== $this->parent) { $this->optionsResolver = clone $this->parent->getOptionsResolver(); } else { $this->optionsResolver = new OptionsResolver(); } $this->innerType->setDefaultOptions($this->optionsResolver); $reflector = new \ReflectionMethod($this->innerType, 'setDefaultOptions'); $isOldOverwritten = $reflector->getDeclaringClass()->getName() !== 'Symfony\\Component\\Form\\AbstractType'; $reflector = new \ReflectionMethod($this->innerType, 'configureOptions'); $isNewOverwritten = $reflector->getDeclaringClass()->getName() !== 'Symfony\\Component\\Form\\AbstractType'; if ($isOldOverwritten && !$isNewOverwritten) { trigger_error('The FormTypeInterface::setDefaultOptions() method is deprecated since version 2.7 and will be removed in 3.0. Use configureOptions() instead. This method will be added to the FormTypeInterface with Symfony 3.0.', E_USER_DEPRECATED); } foreach ($this->typeExtensions as $extension) { $extension->setDefaultOptions($this->optionsResolver); $reflector = new \ReflectionMethod($extension, 'setDefaultOptions'); $isOldOverwritten = $reflector->getDeclaringClass()->getName() !== 'Symfony\\Component\\Form\\AbstractTypeExtension'; $reflector = new \ReflectionMethod($extension, 'configureOptions'); $isNewOverwritten = $reflector->getDeclaringClass()->getName() !== 'Symfony\\Component\\Form\\AbstractTypeExtension'; if ($isOldOverwritten && !$isNewOverwritten) { trigger_error('The FormTypeExtensionInterface::setDefaultOptions() method is deprecated since version 2.7 and will be removed in 3.0. Use configureOptions() instead. This method will be added to the FormTypeExtensionInterface with Symfony 3.0.', E_USER_DEPRECATED); } } } return $this->optionsResolver; }
/** * Returns the configured options resolver used for this type. * * @return \Symfony\Component\OptionsResolver\OptionsResolverInterface The options resolver. */ public function getOptionsResolver() { if (null === $this->optionsResolver) { if (null !== $this->parent) { $this->optionsResolver = clone $this->parent->getOptionsResolver(); } else { $this->optionsResolver = new OptionsResolver(); } $this->innerType->setDefaultOptions($this->optionsResolver); foreach ($this->typeExtensions as $extension) { $extension->setDefaultOptions($this->optionsResolver); } } return $this->optionsResolver; }
private function isFieldSingleUpload(ResolvedFormTypeInterface $formTypeInterface = null) { if ($formTypeInterface == null) { return false; } if ($formTypeInterface->getName() == 'afe_single_upload') { return true; } return $this->isFieldSingleUpload($formTypeInterface->getParent()); }
/** * {@inheritdoc} */ public function addType(ResolvedFormTypeInterface $type) { trigger_error('addType() is deprecated since version 2.1 and will be removed in 2.3. Use form extensions or type registration in the Dependency Injection Container instead.', E_USER_DEPRECATED); $this->types[$type->getName()] = $type; }
/** * {@inheritdoc} */ public function getOptionsResolver() { return $this->proxiedType->getOptionsResolver(); }
/** * {@inheritdoc} */ public function addType(ResolvedFormTypeInterface $type) { $this->types[$type->getName()] = $type; }