protected function computeAssets(BlockContextInterface $blockContext, array &$stats = null)
    {
        if ($blockContext->getBlock()->hasParent()) {
            return;
        }

        $service = $this->blockServiceManager->get($blockContext->getBlock());

        $assets = [
            'js' => $service->getJavascripts('all'),
            'css' => $service->getStylesheets('all'),
        ];

        if (\count($assets['js']) > 0) {
            @trigger_error(
                'Defining javascripts assets inside a block is deprecated since 3.3.0 and will be removed in 4.0',
                E_USER_DEPRECATED
            );
        }

        if (\count($assets['css']) > 0) {
            @trigger_error(
                'Defining css assets inside a block is deprecated since 3.2.0 and will be removed in 4.0',
                E_USER_DEPRECATED
            );
        }

        if ($blockContext->getBlock()->hasChildren()) {
            $iterator = new \RecursiveIteratorIterator(new RecursiveBlockIterator($blockContext->getBlock()->getChildren()));

            foreach ($iterator as $block) {
                $assets = [
                    'js' => array_merge($this->blockServiceManager->get($block)->getJavascripts('all'), $assets['js']),
                    'css' => array_merge($this->blockServiceManager->get($block)->getStylesheets('all'), $assets['css']),
                ];
            }
        }

        if ($this->stopwatch) {
            $stats['assets'] = $assets;
        }

        $this->assets = [
            'js' => array_unique(array_merge($assets['js'], $this->assets['js'])),
            'css' => array_unique(array_merge($assets['css'], $this->assets['css'])),
        ];
    }
protected function computeAssets(BlockContextInterface $blockContext, array &$stats = null)
    {
        if ($blockContext->getBlock()->hasParent()) {
            return;
        }

        $service = $this->blockServiceManager->get($blockContext->getBlock());

        $assets = [
            'js' => $service->getJavascripts('all'),
            'css' => $service->getStylesheets('all'),
        ];

        if (\count($assets['js']) > 0) {
            @trigger_error(
                'Defining javascripts assets inside a block is deprecated since 3.3.0 and will be removed in 4.0',
                E_USER_DEPRECATED
            );
        }

        if (\count($assets['css']) > 0) {
            @trigger_error(
                'Defining css assets inside a block is deprecated since 3.2.0 and will be removed in 4.0',
                E_USER_DEPRECATED
            );
        }

        if ($blockContext->getBlock()->hasChildren()) {
            $iterator = new \RecursiveIteratorIterator(new RecursiveBlockIterator($blockContext->getBlock()->getChildren()));

            foreach ($iterator as $block) {
                $assets = [
                    'js' => array_merge($this->blockServiceManager->get($block)->getJavascripts('all'), $assets['js']),
                    'css' => array_merge($this->blockServiceManager->get($block)->getStylesheets('all'), $assets['css']),
                ];
            }
        }

        if ($this->stopwatch) {
            $stats['assets'] = $assets;
        }

        $this->assets = [
            'js' => array_unique(array_merge($assets['js'], $this->assets['js'])),
            'css' => array_unique(array_merge($assets['css'], $this->assets['css'])),
        ];
    }
protected function computeAssets ( BlockContextInterface $ blockContext , array & $ stats = null ) { if ( $ blockContext -> getBlock ( ) -> hasParent ( ) ) { return ; } $ service = $ this -> blockServiceManager -> get ( $ blockContext -> getBlock ( ) ) ; $ assets = [ 'js' => $ service -> getJavascripts ( 'all' ) , 'css' => $ service -> getStylesheets ( 'all' ) , ] ; if ( \ count ( $ assets [ 'js' ] ) > 0 ) { @ trigger_error ( 'Defining javascripts assets inside a block is deprecated since 3.3.0 and will be removed in 4.0' , E_USER_DEPRECATED ) ; } if ( \ count ( $ assets [ 'css' ] ) > 0 ) { @ trigger_error ( 'Defining css assets inside a block is deprecated since 3.2.0 and will be removed in 4.0' , E_USER_DEPRECATED ) ; } if ( $ blockContext -> getBlock ( ) -> hasChildren ( ) ) { $ iterator = new \ RecursiveIteratorIterator ( new RecursiveBlockIterator ( $ blockContext -> getBlock ( ) -> getChildren ( ) ) ) ; foreach ( $ iterator as $ block ) { $ assets = [ 'js' => array_merge ( $ this -> blockServiceManager -> get ( $ block ) -> getJavascripts ( 'all' ) , $ assets [ 'js' ] ) , 'css' => array_merge ( $ this -> blockServiceManager -> get ( $ block ) -> getStylesheets ( 'all' ) , $ assets [ 'css' ] ) , ] ; } } if ( $ this -> stopwatch ) { $ stats [ 'assets' ] = $ assets ; } $ this -> assets = [ 'js' => array_unique ( array_merge ( $ assets [ 'js' ] , $ this -> assets [ 'js' ] ) ) , 'css' => array_unique ( array_merge ( $ assets [ 'css' ] , $ this -> assets [ 'css' ] ) ) , ] ; }
Traverse the parent block and its children to retrieve the correct list css and javascript only for main block.

@param BlockContextInterface $blockContext
@param array                 $stats
Traverse the parent block and its children to retrieve the correct list css and javascript only for main block .