Skip to content

Access Childs from a BlockBlockΒ #38

@dowitsch

Description

@dowitsch

I have a definition which extends a other definition and want to add a content to a a block which is inside two other BlockBlock. It is possible to access the child Blocks but it is pretty ugly:

    public function configureView(DefinitionBuilder $builder, $data): void
    {
        parent::configureView($builder, $data);

        // does work
        $shipmentBlock = $builder->getBlock('topLevelBlock')->getBlocks()['rightGridBlock']->getBlocks()['shipment'];
        
        // how I would like it to work
        $shipmentBlock = $builder->getBlock('shipment');
    }

Also Phpstan does not really like this solution because getBlock return an instance of Block and not BlockBlock which contains the getBlocks method. So you have to work with multiple annotations to define the var or ignore the line.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions