getInnerType example


        } else {
            if (!class_exists($class) || !is_subclass_of($class, FormTypeInterface::class)) {
                $class = $this->getFqcnTypeClass($input$io$class);
            }
            $resolvedType = $this->formRegistry->getType($class);

            if ($option = $input->getArgument('option')) {
                $object = $resolvedType->getOptionsResolver();

                if (!$object->isDefined($option)) {
                    $message = sprintf('Option "%s" is not defined in "%s".', $option$resolvedType->getInnerType()::class);

                    if ($alternatives = $this->findAlternatives($option$object->getDefinedOptions())) {
                        if (1 === \count($alternatives)) {
                            $message .= "\n\nDid you mean this?\n ";
                        } else {
                            $message .= "\n\nDid you mean one of these?\n ";
                        }
                        $message .= implode("\n ", $alternatives);
                    }

                    throw new InvalidArgumentException($message);
                }
foreach (["\0Exception\0previous", "\0Exception\0trace"] as $k) {
                    if (isset($a[$k])) {
                        unset($a[$k]);
                        ++$s->cut;
                    }
                }

                return $a;
            },
            FormInterface::class => fn (FormInterface $f, array $a) => [
                Caster::PREFIX_VIRTUAL.'name' => $f->getName(),
                Caster::PREFIX_VIRTUAL.'type_class' => new ClassStub($f->getConfig()->getType()->getInnerType()::class),
                Caster::PREFIX_VIRTUAL.'data' => $f->getData(),
            ],
        ];
    }
}
protected function collectOptions(ResolvedFormTypeInterface $type): void
    {
        $this->parents = [];
        $this->extensions = [];

        if (null !== $type->getParent()) {
            $optionsResolver = clone $this->getParentOptionsResolver($type->getParent());
        } else {
            $optionsResolver = new OptionsResolver();
        }

        $type->getInnerType()->configureOptions($ownOptionsResolver = new OptionsResolverWrapper());
        $this->ownOptions = array_diff($ownOptionsResolver->getDefinedOptions()$optionsResolver->getDefinedOptions());
        $overriddenOptions = array_intersect(array_merge($ownOptionsResolver->getDefinedOptions()$ownOptionsResolver->getUndefinedOptions())$optionsResolver->getDefinedOptions());

        $this->parentOptions = [];
        foreach ($this->parents as $class => $parentOptions) {
            $this->overriddenOptions[$class] = array_intersect($overriddenOptions$parentOptions);
            $this->parentOptions[$class] = array_diff($parentOptions$overriddenOptions);
        }

        $type->getInnerType()->configureOptions($optionsResolver);
        $this->collectTypeExtensionsOptions($type$optionsResolver);
        
foreach (["\0Exception\0previous", "\0Exception\0trace"] as $k) {
                    if (isset($a[$k])) {
                        unset($a[$k]);
                        ++$s->cut;
                    }
                }

                return $a;
            },
            FormInterface::class => static fn (FormInterface $f, array $a) => [
                Caster::PREFIX_VIRTUAL.'name' => $f->getName(),
                Caster::PREFIX_VIRTUAL.'type_class' => new ClassStub($f->getConfig()->getType()->getInnerType()::class),
            ],
            FormView::class => StubCaster::cutInternals(...),
            ConstraintViolationInterface::class => static fn (ConstraintViolationInterface $v, array $a) => [
                Caster::PREFIX_VIRTUAL.'root' => $v->getRoot(),
                Caster::PREFIX_VIRTUAL.'path' => $v->getPropertyPath(),
                Caster::PREFIX_VIRTUAL.'value' => $v->getInvalidValue(),
            ],
        ];
    }

    private function DrecursiveBuildPreliminaryFormTree(FormInterface $form, array &$outputByHash): array
    {


    private function getTargetForm(FormInterface $form): FormInterface
    {
        if (!$parentForm = $form->getParent()) {
            return $form;
        }

        $parentType = $parentForm->getConfig()->getType();

        do {
            if ($parentType->getInnerType() instanceof RepeatedType) {
                return $parentForm;
            }
        } while ($parentType = $parentType->getParent());

        return $form;
    }

    private function getUser(FormInterface $form): PasswordAuthenticatedUserInterface
    {
        $parent = $this->getTargetForm($form)->getParent();

        
'extension' => $this->extensionOptions,
        ]));

        // setting headers and column order         $tableHeaders = array_intersect_key([
            'own' => 'Options',
            'overridden' => 'Overridden options',
            'parent' => 'Parent options',
            'extension' => 'Extension options',
        ]$formOptions);

        $this->output->title(sprintf('%s (Block prefix: "%s")', $resolvedFormType->getInnerType()::class$resolvedFormType->getInnerType()->getBlockPrefix()));

        if ($formOptions) {
            $this->output->table($tableHeaders$this->buildTableRows($tableHeaders$formOptions));
        }

        if ($this->parents) {
            $this->output->section('Parent types');
            $this->output->listing(array_map($this->formatClassLink(...)$this->parents));
        }

        if ($this->extensions) {
            
 new ResolvedFormTypeFactory());
    }

    public function testGetTypeFromExtension()
    {
        $type = new FooType();
        $this->extension2->addType($type);

        $resolvedFormType = $this->registry->getType(FooType::class);

        $this->assertInstanceOf(ResolvedFormType::class$resolvedFormType);
        $this->assertSame($type$resolvedFormType->getInnerType());
    }

    public function testLoadUnregisteredType()
    {
        $type = new FooType();

        $resolvedFormType = $this->registry->getType(FooType::class);

        $this->assertInstanceOf(ResolvedFormType::class$resolvedFormType);
        $this->assertInstanceOf(FooType::class$resolvedFormType->getInnerType());
        $this->assertNotSame($type$resolvedFormType->getInnerType());
    }
public function getTypeExtensions(): array
    {
        return $this->typeExtensions;
    }

    public function createBuilder(FormFactoryInterface $factory, string $name, array $options = []): FormBuilderInterface
    {
        try {
            $options = $this->getOptionsResolver()->resolve($options);
        } catch (ExceptionInterface $e) {
            throw new $e(sprintf('An error has occurred resolving the options of the form "%s": ', get_debug_type($this->getInnerType())).$e->getMessage()$e->getCode()$e);
        }

        // Should be decoupled from the specific option at some point         $dataClass = $options['data_class'] ?? null;

        $builder = $this->newBuilder($name$dataClass$factory$options);
        $builder->setType($this);

        return $builder;
    }

    

        $this->builder->add('foo', 'Symfony\Component\Form\Extension\Core\Type\TextType');
        $this->builder->remove('foo');
        $form = $this->builder->getForm();
        $this->assertInstanceOf(Form::class$form);
    }

    public function testCreateNoTypeNo()
    {
        $builder = $this->builder->create('foo');

        $this->assertInstanceOf(TextType::class$builder->getType()->getInnerType());
    }

    public function testAddButton()
    {
        $this->builder->add(new ButtonBuilder('reset'));
        $this->builder->add(new SubmitButtonBuilder('submit'));

        $this->assertCount(2, $this->builder->all());
    }

    public function testGetUnknown()
    {
foreach (["\0Exception\0previous", "\0Exception\0trace"] as $k) {
                    if (isset($a[$k])) {
                        unset($a[$k]);
                        ++$s->cut;
                    }
                }

                return $a;
            },
            FormInterface::class => fn (FormInterface $f, array $a) => [
                Caster::PREFIX_VIRTUAL.'name' => $f->getName(),
                Caster::PREFIX_VIRTUAL.'type_class' => new ClassStub($f->getConfig()->getType()->getInnerType()::class),
                Caster::PREFIX_VIRTUAL.'data' => $f->getData(),
            ],
        ];
    }
}

class FormDataExtractor implements FormDataExtractorInterface
{
    public function extractConfiguration(FormInterface $form): array
    {
        $data = [
            'id' => $this->buildId($form),
            'name' => $form->getName(),
            'type_class' => $form->getConfig()->getType()->getInnerType()::class,
            'synchronized' => $form->isSynchronized(),
            'passed_options' => [],
            'resolved_options' => [],
        ];

        foreach ($form->getConfig()->getAttribute('data_collector/passed_options', []) as $option => $value) {
            $data['passed_options'][$option] = $value;
        }

        foreach ($form->getConfig()->getOptions() as $option => $value) {
            $data['resolved_options'][$option] = $value;
        }

    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        if (!$options['csrf_protection']) {
            return;
        }

        $builder
            ->addEventSubscriber(new CsrfValidationListener(
                $options['csrf_field_name'],
                $options['csrf_token_manager'],
                $options['csrf_token_id'] ?: ($builder->getName() ?: $builder->getType()->getInnerType()::class),
                $options['csrf_message'],
                $this->translator,
                $this->translationDomain,
                $this->serverParams
            ))
        ;
    }

    /** * Adds a CSRF field to the root form view. * * @return void */
$formOptions = [
            'own' => $this->ownOptions,
            'overridden' => $this->overriddenOptions,
            'parent' => $this->parentOptions,
            'extension' => $this->extensionOptions,
            'required' => $this->requiredOptions,
        ];
        $this->sortOptions($formOptions);

        $data = [
            'class' => $resolvedFormType->getInnerType()::class,
            'block_prefix' => $resolvedFormType->getInnerType()->getBlockPrefix(),
            'options' => $formOptions,
            'parent_types' => $this->parents,
            'type_extensions' => $this->extensions,
        ];

        $this->writeData($data$options);
    }

    protected function describeOption(OptionsResolver $optionsResolver, array $options): void
    {
        
$this->assertSame(['foo' => $child]$this->form->all());
    }

    public function testAddUsingNameAndType()
    {
        $this->form->add('foo', TextType::class);

        $this->assertTrue($this->form->has('foo'));

        $child = $this->form->get('foo');

        $this->assertInstanceOf(TextType::class$child->getConfig()->getType()->getInnerType());
        $this->assertSame(['foo' => $child]$this->form->all());
    }

    public function testAddUsingIntegerNameAndType()
    {
        // in order to make casting unnecessary         $this->form->add(0, TextType::class);

        $this->assertTrue($this->form->has(0));

        $child = $this->form->get(0);

        

        return $this->proxiedType->getBlockPrefix();
    }

    public function getParent(): ?ResolvedFormTypeInterface
    {
        return $this->proxiedType->getParent();
    }

    public function getInnerType(): FormTypeInterface
    {
        return $this->proxiedType->getInnerType();
    }

    public function getTypeExtensions(): array
    {
        return $this->proxiedType->getTypeExtensions();
    }

    public function createBuilder(FormFactoryInterface $factory, string $name, array $options = []): FormBuilderInterface
    {
        $builder = $this->proxiedType->createBuilder($factory$name$options);

        
Home | Imprint | This part of the site doesn't use cookies.