Skip to content

Error getting Block in controller Magento 2: Element ‘block’, attribute ‘class’: [facet ‘pattern’]

I’m trying to get block in my frontend controller like this:

$resultPage = $this->resultPageFactory->create();
$breadcrumbs = $resultPage->getLayout()->getBlock('breadcrumbs');

this is my XML file layout

<?xml version="1.0" ?>
<page layout="1column" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceContainer name="content">
            <block class="VendorModuleBlockViewIndex" name="promotion.view.categories" template="Vendor_Module::view/index.phtml">
                <block class="MagentoFrameworkViewElementTemplate" name="promotion.view.subcategories.wrapper"/>
            </block>
        </referenceContainer>
    </body>
</page>

i always get an error like this:

Exception #0 (MagentoFrameworkConfigDomValidationException): Element 'block', attribute 'class': [facet 'pattern'] The value 'MagentoFrameworkViewElementTemplate' is not accepted by the pattern '[A-Z][_a-zA-Zd]*(\[A-Z][_a-zA-Zd]*)*'.