Magento Extensions Rating 2024
EXTENSIONS BY CATEGORY
B2B (Business-To-Business)
Blog
Customer
ERP (Enterprise Resource Planning)
Mega Menu
One Step Checkout
Order
POS (Point Of Sale)
Search
Shopping Cart
Sitemap
SEO
Social
Stock & Inventory Management
EXTENSIONS BY DEVELOPER
aheadWorks
Amasty
Boost My Shop
BSS Commerce
Magestore
MageWorx
Mirasvit
Templates Master
Wyomind
XTENTO
Magento 2 Documentation
Magento 2 Documentation
2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
vendor
magento
module-cms-graph-ql
Model
Resolver
DataProvider
Block.php
Go to the documentation of this file.
1
<?php
6
declare(strict_types=1);
7
8
namespace
Magento\CmsGraphQl\Model\Resolver\DataProvider
;
9
10
use
Magento\Cms\Api\BlockRepositoryInterface
;
11
use
Magento\Cms\Api\Data\BlockInterface
;
12
use
Magento\Framework\Exception\NoSuchEntityException
;
13
use
Magento\Widget\Model\Template\FilterEmulate
;
14
18
class
Block
19
{
23
private
$blockRepository;
24
28
private
$widgetFilter;
29
34
public
function
__construct
(
35
BlockRepositoryInterface
$blockRepository,
36
FilterEmulate
$widgetFilter
37
) {
38
$this->blockRepository =
$blockRepository
;
39
$this->widgetFilter = $widgetFilter;
40
}
41
47
public
function
getData
(
string
$blockIdentifier): array
48
{
49
$block
= $this->blockRepository->getById($blockIdentifier);
50
51
if
(
false
===
$block
->isActive()) {
52
throw
new
NoSuchEntityException
();
53
}
54
55
$renderedContent = $this->widgetFilter->filter(
$block
->getContent());
56
57
$blockData = [
58
BlockInterface::IDENTIFIER
=>
$block
->getIdentifier(),
59
BlockInterface::TITLE
=>
$block
->getTitle(),
60
BlockInterface::CONTENT
=> $renderedContent,
61
];
62
return
$blockData;
63
}
64
}
Magento\Cms\Api\BlockRepositoryInterface
Definition:
BlockRepositoryInterface.php:13
Magento\CmsGraphQl\Model\Resolver\DataProvider
Definition:
Block.php:8
Magento\Cms\Api\Data\BlockInterface\CONTENT
const CONTENT
Definition:
BlockInterface.php:21
Magento\Cms\Api\Data\BlockInterface\IDENTIFIER
const IDENTIFIER
Definition:
BlockInterface.php:19
$blockRepository
$blockRepository
Definition:
block_rollback.php:16
$block
$block
Definition:
block.php:8
Magento\Cms\Api\Data\BlockInterface\TITLE
const TITLE
Definition:
BlockInterface.php:20
Magento\Cms\Api\Data\BlockInterface
Definition:
BlockInterface.php:13
Magento\CmsGraphQl\Model\Resolver\DataProvider\Block
Definition:
Block.php:18
Magento\CmsGraphQl\Model\Resolver\DataProvider\Block\__construct
__construct(BlockRepositoryInterface $blockRepository, FilterEmulate $widgetFilter)
Definition:
Block.php:34
Magento\Widget\Model\Template\FilterEmulate
Definition:
FilterEmulate.php:8
Magento\CmsGraphQl\Model\Resolver\DataProvider\Block\getData
getData(string $blockIdentifier)
Definition:
Block.php:47
Magento\Framework\Exception\NoSuchEntityException
Definition:
NoSuchEntityException.php:16