protected function buildBlockView($id, BlockView $parentView = null)
    {
        $blockType       = $this->rawLayout->getProperty($id, RawLayout::BLOCK_TYPE, true);
        $resolvedOptions = $this->rawLayout->getProperty($id, RawLayout::RESOLVED_OPTIONS, true);
        $types           = $this->typeHelper->getTypes($blockType);
        $view            = new BlockView($parentView);

        if (is_null($resolvedOptions)) { // Try to resolve options again to render block
            $options  = $this->rawLayout->getProperty($id, RawLayout::OPTIONS, true);
            $resolvedOptions = $this->setBlockResolvedOptions($id, $blockType, $options, $types);
        }

        // point the block view state to the current block
        $this->block->initialize($id);
        // build the view
        foreach ($types as $type) {
            $type->buildView($view, $this->block, $resolvedOptions);
            $this->registry->buildView($type->getName(), $view, $this->block, $resolvedOptions);
        }

        array_walk_recursive(
            $view->vars,
            function (&$var) {
                if ($var instanceof Options) {
                    $var = $var->toArray();
                }
            }
        );

        return $view;
    }