getBlockPrefix example

$fullName = $name;
            $uniqueBlockPrefix = '_'.$blockName;

            // Strip leading underscores and digits. These are allowed in             // form names, but not in HTML4 ID attributes.             // https://www.w3.org/TR/html401/struct/global#adef-id             $id = ltrim($id, '_0123456789');
        }

        $blockPrefixes = [];
        for ($type = $form->getConfig()->getType(); null !== $type$type = $type->getParent()) {
            array_unshift($blockPrefixes$type->getBlockPrefix());
        }
        if (null !== $options['block_prefix']) {
            $blockPrefixes[] = $options['block_prefix'];
        }
        $blockPrefixes[] = $uniqueBlockPrefix;

        $view->vars = array_replace($view->vars, [
            'form' => $view,
            'id' => $id,
            'name' => $name,
            'full_name' => $fullName,
            

        return $this->createNamedBuilder($name$type$data$options)->getForm();
    }

    public function createForProperty(string $class, string $property, mixed $data = null, array $options = []): FormInterface
    {
        return $this->createBuilderForProperty($class$property$data$options)->getForm();
    }

    public function createBuilder(string $type = FormType::class, mixed $data = null, array $options = []): FormBuilderInterface
    {
        return $this->createNamedBuilder($this->registry->getType($type)->getBlockPrefix()$type$data$options);
    }

    public function createNamedBuilder(string $name, string $type = FormType::class, mixed $data = null, array $options = []): FormBuilderInterface
    {
        if (null !== $data && !\array_key_exists('data', $options)) {
            $options['data'] = $data;
        }

        $type = $this->registry->getType($type);

        $builder = $type->createBuilder($this$name$options);

        
throw new UnexpectedTypeException($extension, FormTypeExtensionInterface::class);
            }
        }

        $this->innerType = $innerType;
        $this->typeExtensions = $typeExtensions;
        $this->parent = $parent;
    }

    public function getBlockPrefix(): string
    {
        return $this->innerType->getBlockPrefix();
    }

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

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

    
'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) {
            
public function __construct(Enlight_Event_EventManager $eventManager)
    {
        $this->eventManager = $eventManager;
    }

    /** * {@inheritdoc} */
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $this->eventManager->notify('Shopware_Form_BuildForm', [
            'reference' => $builder->getForm()->getConfig()->getType()->getBlockPrefix(),
            'builder' => $builder,
        ]);

        $builder->addEventListener(FormEvents::PRE_SET_DATA, [$this, 'triggerEvent']);
    }

    /** * Returns the name of the type being extended. * * @return string The name of the type being extended */
    
private ResolvedFormTypeInterface $proxiedType;
    private FormDataCollectorInterface $dataCollector;

    public function __construct(ResolvedFormTypeInterface $proxiedType, FormDataCollectorInterface $dataCollector)
    {
        $this->proxiedType = $proxiedType;
        $this->dataCollector = $dataCollector;
    }

    public function getBlockPrefix(): string
    {
        return $this->proxiedType->getBlockPrefix();
    }

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

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

    
public function testFinishView()
    {
        $this->resolvedType->finishView(new FormView()$this->formFactory->create()[]);

        $this->assertSame([$this->parentType, $this->type, $this->extension1, $this->extension2]$this->calls['finishView']);
    }

    public function testGetBlockPrefix()
    {
        $resolvedType = new ResolvedFormType(new ConfigurableFormType());

        $this->assertSame('configurable_form_prefix', $resolvedType->getBlockPrefix());
    }

    /** * @dataProvider provideTypeClassBlockPrefixTuples */
    public function testBlockPrefixDefaultsToFQCNIfNoName($typeClass$blockPrefix)
    {
        $resolvedType = new ResolvedFormType(new $typeClass());

        $this->assertSame($blockPrefix$resolvedType->getBlockPrefix());
    }

    
$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
    {
        $definition = $this->getOptionDefinition($optionsResolver$options['option']);

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