コード例 #1
0
 /**
  * @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);
 }
コード例 #2
0
 /**
  * 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;
 }
コード例 #3
0
 public static function isType(ResolvedFormTypeInterface $type, $typeName)
 {
     do {
         if ($type->getName() === $typeName) {
             return true;
         }
         $type = $type->getParent();
     } while ($type !== null);
     return false;
 }
コード例 #4
0
 /**
  * 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;
 }
コード例 #5
0
ファイル: ResolvedFormType.php プロジェクト: aleksabp/bolt
 /**
  * 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());
 }
コード例 #7
0
ファイル: FormRegistry.php プロジェクト: ronnylt/symfony
 /**
  * {@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;
 }
コード例 #8
0
 /**
  * {@inheritdoc}
  */
 public function getOptionsResolver()
 {
     return $this->proxiedType->getOptionsResolver();
 }
コード例 #9
0
ファイル: FormRegistry.php プロジェクト: nextmotion/symfony
 /**
  * {@inheritdoc}
  */
 public function addType(ResolvedFormTypeInterface $type)
 {
     $this->types[$type->getName()] = $type;
 }