src/Model/Page.php
public function getContainerByCode($code)
    {
        $block = null;

        foreach ($this->getBlocks() as $blockTmp) {
            if (\in_array($blockTmp->getType(), ['sonata.page.block.container', 'sonata.block.service.container'], true) && $blockTmp->getSetting('code') === $code) {
                $block = $blockTmp;

                break;
            }
        }

        return $block;
    }
public function getContainerByCode($code)
    {
        $block = null;

        foreach ($this->getBlocks() as $blockTmp) {
            if (\in_array($blockTmp->getType(), ['sonata.page.block.container', 'sonata.block.service.container'], true) && $blockTmp->getSetting('code') === $code) {
                $block = $blockTmp;

                break;
            }
        }

        return $block;
    }
public function getContainerByCode ( $ code ) { $ block = null ; foreach ( $ this -> getBlocks ( ) as $ blockTmp ) { if ( \ in_array ( $ blockTmp -> getType ( ) , [ 'sonata.page.block.container' , 'sonata.block.service.container' ] , true ) && $ blockTmp -> getSetting ( 'code' ) === $ code ) { $ block = $ blockTmp ; break ; } } return $ block ; }
Retrieve a block by code.

@param string $code

@return PageBlockInterface
Retrieve a block by code .